-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up match_quantiles function for ComBat_seq functon #48
Open
lrf2019
wants to merge
135
commits into
RELEASE_3_9
Choose a base branch
from
master
base: RELEASE_3_9
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59266 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59266 bc3139a8-67e5-0310-9ffc-ced21a209358
…) added man files for ComBat git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59673 bc3139a8-67e5-0310-9ffc-ced21a209358
…) added man files for ComBat git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59673 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59716 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59716 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59717 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59717 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59920 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59920 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59924 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@59924 bc3139a8-67e5-0310-9ffc-ced21a209358
…n of setting num.sv method in sva. Fixed a bug in Combat so only an intercept term can be included git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@60980 bc3139a8-67e5-0310-9ffc-ced21a209358
…n of setting num.sv method in sva. Fixed a bug in Combat so only an intercept term can be included git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@60980 bc3139a8-67e5-0310-9ffc-ced21a209358
…o use method leek git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@61130 bc3139a8-67e5-0310-9ffc-ced21a209358
…o use method leek git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@61130 bc3139a8-67e5-0310-9ffc-ced21a209358
…the list, updated fsva to include the new fast method as well as the original method git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@63723 bc3139a8-67e5-0310-9ffc-ced21a209358
…the list, updated fsva to include the new fast method as well as the original method git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@63723 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@64678 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@64678 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@64680 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@64680 bc3139a8-67e5-0310-9ffc-ced21a209358
…rom being built. removed bug in fsva where svs where being normalized incorrectly for the exact case. git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@65411 bc3139a8-67e5-0310-9ffc-ced21a209358
…rom being built. removed bug in fsva where svs where being normalized incorrectly for the exact case. git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@65411 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@69763 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@69763 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@70050 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@70050 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@70052 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@70052 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@130304 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@130416 bc3139a8-67e5-0310-9ffc-ced21a209358
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/sva@130528 bc3139a8-67e5-0310-9ffc-ced21a209358
Changed two occurences of `cat()` to `message()` in ComBat so they can be suppressed. All the other printing in ComBat already uses `message()`.
Update ComBat.R
…hical parameters and reset to those after the 2x2 plot is made
…at matrix input for sva_network; input data is uncorrected normalized gene expression data; update example code accordingly
update documentation for sva_network
When plotting ComBat prior.plots, save the original state of the graphical parameters
Adding combat-seq to sva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
match_quantiles <- function(counts_sub, old_mu, old_phi, new_mu, new_phi){
new_counts_sub <- matrix(NA, nrow=nrow(counts_sub), ncol=ncol(counts_sub))
for(a in 1:nrow(counts_sub)){
for(b in 1:ncol(counts_sub)){
if(counts_sub[a, b] <= 1){
new_counts_sub[a,b] <- counts_sub[a, b]
}else{
tmp_p <- pnbinom(counts_sub[a, b]-1, mu=old_mu[a, b], size=1/old_phi[a])
if(abs(tmp_p-1)<1e-4){
new_counts_sub[a,b] <- counts_sub[a, b]
# for outlier count, if p==1, will return Inf values -> use original count instead
}else{
new_counts_sub[a,b] <- 1+qnbinom(tmp_p, mu=new_mu[a, b], size=1/new_phi[a])
}
}
}
}
return(new_counts_sub)
}
new code for speed up this function
1. use which to transfer matrix boolean calculation to array boolean calculation to speed up
2. use matrix calculation to replace two for cycles to speed up the new matrix generation
match_quantiles_new <- function(counts_sub, old_mu, old_phi, new_mu, new_phi){
new_counts_sub <- counts_sub
condition1 <- which( counts_sub > 1) # array boolean calculation
colid <- floor(condition1/nrow(counts_sub)) + 1 # calculate the colid for rowid calculation
rowid <- condition1 - (colid - 1)*nrow(counts_sub) # calculate rowid for old_phi and new_phi value selection
tmp_p <- pnbinom(counts_sub[condition1] - 1, mu = old_mu[condition1], size = 1/old_phi[rowid])
tmp_q <- 1 + qnbinom(tmp_p[condition1], mu = new_mu[condition1], size = 1/new_phi[rowid])
condition2 <- which((abs(tmp_p-1) >= 1e-4))
new_counts_sub[ condition1[condition2] ] = tmp_q[condition2]
return(new_counts_sub)
}