-
Notifications
You must be signed in to change notification settings - Fork 71
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
Removed pairwise batch effect checks from WDL workflow #617
Open
shadizaheri
wants to merge
12
commits into
main
Choose a base branch
from
sz_no_pairwise_batch_effect
base: main
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.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
43a93f1
add toggle for unstable af filter during label step in batch effect
epiercehoffman 38e11d6
skip AF comparison and filtering if no input provided
epiercehoffman 682ca8f
make af input actually optional
epiercehoffman 37662c8
Removed pairwise batch effect checks from WDL workflow
shadizaheri b691bd6
no_pairwise_no_unstable_af_filter
shadizaheri a97bc39
Merge branch 'eph_turn_off_unstable_af_filter' into sz_no_pairwise_ba…
shadizaheri 592d93a
updated the related wdl and R script
shadizaheri 3533181
updated the related wdl and deleted the copy of the wdl
shadizaheri baba8aa
Update make_batch_effect_reclassification_table.PCRMinus_only.R
shadizaheri b253052
Update Module07XfBatchEffect.wdl
shadizaheri 54c421e
Update Module07XfBatchEffect.wdl
shadizaheri 30647d3
Update make_batch_effect_reclassification_table.PCRMinus_only.R
shadizaheri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -54,32 +54,17 @@ import.fails <- function(minus.in,prefix){ | |||
} | ||||
|
||||
#Categorize failing sites | ||||
categorize.failures <- function(dat,pairwise.cutoff,onevsall.cutoff){ | ||||
dat$max_plus_frac <- apply(data.frame(dat$frac_plus_fails_pairwise, | ||||
dat$frac_plus_fails_onevsall), | ||||
categorize.failures <- function(dat,onevsall.cutoff){ | ||||
dat$max_plus_frac <- apply(data.frame(dat$frac_plus_fails_onevsall), | ||||
1,max,na.rm=T) | ||||
pairwise.fail.idx <- which(dat$fails_pairwise>=pairwise.cutoff & dat$fails_onevsall<onevsall.cutoff) | ||||
onevsall.fail.idx <- which(dat$fails_pairwise<pairwise.cutoff & dat$fails_onevsall>=onevsall.cutoff) | ||||
both.fail.idx <- which(dat$fails_pairwise>=pairwise.cutoff & dat$fails_onevsall>=onevsall.cutoff) | ||||
onevsall.fail.idx <- which(dat$fails_onevsall>=onevsall.cutoff) | ||||
plus.gt.minus <- which(dat$PCRPLUS_AF>=dat$PCRMINUS_AF) | ||||
minus.gt.plus <- which(dat$PCRPLUS_AF<dat$PCRMINUS_AF) | ||||
|
||||
#Build vectors of VIDs for each category | ||||
plus.enriched <- c() | ||||
plus.depleted <- c() | ||||
batch.variable <- c() | ||||
for(i in pairwise.fail.idx){ | ||||
row <- dat[i,] | ||||
if(as.numeric(row$frac_plus_fails_pairwise)>=0.11){ | ||||
if(as.numeric(row$PCRPLUS_AF)>=as.numeric(row$PCRMINUS_AF)){ | ||||
plus.enriched <- c(plus.enriched,i) | ||||
}else{ | ||||
plus.depleted <- c(plus.depleted,i) | ||||
} | ||||
}else{ | ||||
batch.variable <- c(batch.variable,i) | ||||
} | ||||
} | ||||
for(i in onevsall.fail.idx){ | ||||
row <- dat[i,] | ||||
if(as.numeric(row$frac_plus_fails_onevsall)>=0.11){ | ||||
|
@@ -92,18 +77,6 @@ categorize.failures <- function(dat,pairwise.cutoff,onevsall.cutoff){ | |||
batch.variable <- c(batch.variable,i) | ||||
} | ||||
} | ||||
for(i in both.fail.idx){ | ||||
row <- dat[i,] | ||||
if(as.numeric(row$max_plus_frac)>=0.11){ | ||||
if(as.numeric(row$PCRPLUS_AF)>=as.numeric(row$PCRMINUS_AF)){ | ||||
plus.enriched <- c(plus.enriched,i) | ||||
}else{ | ||||
plus.depleted <- c(plus.depleted,i) | ||||
} | ||||
}else{ | ||||
batch.variable <- c(batch.variable,i) | ||||
} | ||||
} | ||||
|
||||
#Build classification table | ||||
out.table <- data.frame("VID"=dat$VID[c(plus.enriched,plus.depleted,batch.variable)], | ||||
|
@@ -118,13 +91,13 @@ categorize.failures <- function(dat,pairwise.cutoff,onevsall.cutoff){ | |||
###Read command-line arguments | ||||
args <- commandArgs(trailingOnly=T) | ||||
freq.table.in <- as.character(args[1]) | ||||
pairwise.in <- as.character(args[2]) | ||||
#pairwise.in <- as.character(args[2]) | ||||
#pairwise.minus.in <- as.character(args[3]) | ||||
onevsall.in <- as.character(args[3]) | ||||
onevsall.in <- as.character(args[2]) | ||||
#onevsall.minus.in <- as.character(args[5]) | ||||
OUTFILE <- as.character(args[4]) | ||||
pairwise.cutoff <- as.integer(args[5]) | ||||
onevsall.cutoff <- as.integer(args[6]) | ||||
OUTFILE <- as.character(args[3]) | ||||
#pairwise.cutoff <- as.integer(args[5]) | ||||
onevsall.cutoff <- as.integer(args[4]) | ||||
|
||||
# #Dev parameters: | ||||
# freq.table.in <- "~/scratch/gnomAD_v2_SV_MASTER.merged_AF_table.txt.gz" | ||||
|
@@ -139,27 +112,28 @@ onevsall.cutoff <- as.integer(args[6]) | |||
freq.dat <- import.freqs(freq.table.in) | ||||
|
||||
|
||||
pairwise.fails <- import.fails(pairwise.in, prefix="pairwise") | ||||
pairwise.fails <- pairwise.fails[which(pairwise.fails$fails_pairwise>=pairwise.cutoff), ] | ||||
onevsall.fails <- import.fails(onevsall.in, prefix="onevsall") | ||||
onevsall.fails <- onevsall.fails[which(onevsall.fails$fails_onevsall>=onevsall.cutoff), ] | ||||
|
||||
|
||||
###Combine data | ||||
merged <- merge(pairwise.fails,onevsall.fails,all=T,sort=F,by="VID") | ||||
if(nrow(merged) > 0){ | ||||
merged[,-1] <- apply(merged[,-1],2,function(vals){ | ||||
#merged <- merge(onevsall.fails,all=T,sort=F,by="VID") | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
merged <- onevsall.fails | ||||
# If merged data frame is not empty, replace NA values with 0 | ||||
if (nrow(merged) > 0) { | ||||
merged[,-1] <- apply(merged[,-1], 2, function(vals) { | ||||
vals[which(is.na(vals))] <- 0 | ||||
return(vals) | ||||
}) | ||||
} | ||||
merged <- merge(merged,freq.dat,by="VID",sort=F,all=F) | ||||
|
||||
# Merge with frequency data | ||||
merged <- merge(merged, freq.dat, by = "VID", sort = F, all = F) | ||||
|
||||
##Categorize batch effect failure sites | ||||
out.table <- categorize.failures(dat=merged, | ||||
pairwise.cutoff=pairwise.cutoff, | ||||
onevsall.cutoff=onevsall.cutoff) | ||||
write.table(out.table,OUTFILE,col.names=F,row.names=F,sep="\t",quote=F) | ||||
## Categorize batch effect failure sites | ||||
# Assuming the categorize.failures function only requires onevsall.cutoff | ||||
# and is compatible with the new merged data structure | ||||
out.table <- categorize.failures(dat = merged, onevsall.cutoff = onevsall.cutoff) | ||||
|
||||
|
||||
# Write the output table | ||||
write.table(out.table, OUTFILE, col.names = F, row.names = F, sep = "\t", quote = F) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to fully remove pairwise checks it would be cleaner to delete these lines rather than commenting them out