Skip to content

Commit

Permalink
fix switching between fraser versions to start from right script
Browse files Browse the repository at this point in the history
  • Loading branch information
ischeller committed Apr 13, 2023
1 parent 29663fa commit 54d157b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#' - counting_done: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/raw-local-{dataset}/counting.done" `'
#' output:
#' - theta: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/raw-local-{dataset}/theta.h5"`'
#' - splice_metrics: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/raw-local-{dataset}/{type}.h5", type=cfg.AS.getPsiTypeAssay(), allow_missing=True)`'
#' type: script
#'---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#' - workingDir: '`sm cfg.getProcessedDataDir() + "/aberrant_splicing/datasets/"`'
#' - exCountIDs: '`sm lambda w: sa.getIDsByGroup(w.dataset, assay="SPLICE_COUNT")`'
#' input:
#' - theta: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/raw-local-{dataset}/theta.h5"`'
#' - splice_metrics: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/raw-local-{dataset}/{type}.h5", type=cfg.AS.getPsiTypeAssay(), allow_missing=True)`'
#' - exCounts: '`sm lambda w: cfg.AS.getExternalCounts(w.dataset, "k_j_counts")`'
#' output:
#' - fds: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/fds-object.RDS"`'
#' - done: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/filter.done" `'
#' - done: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/filter_{version}.done", version=cfg.AS.get("FRASER_version"), allow_missing=True)`'
#' threads: 3
#' type: script
#'---
Expand Down Expand Up @@ -97,4 +97,9 @@ if (params$filter == TRUE) {
seqlevels(fds) <- seqlevelsInUse(fds)
colData(fds)$sampleID <- as.character(colData(fds)$sampleID)
fds <- saveFraserDataSet(fds,dir = workingDir)

# remove previous filter.done files and create new one
outdir <- dirname(snakemake@output$done)
prevFilterFiles <- grep("filter(.*)done", list.files(outdir), value=TRUE)
unlink(file.path(outdir, prevFilterFiles))
file.create(snakemake@output$done)
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#' - workingDir: '`sm cfg.getProcessedDataDir() + "/aberrant_splicing/datasets/"`'
#' threads: 12
#' input:
#' - filter: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/filter.done" `'
#' - filter: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/filter_{version}.done", version=cfg.AS.get("FRASER_version"), allow_missing=True)`'
#' output:
#' - hyper: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/hyper.done" `'
#' - hyper: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/hyper_{version}.done", version=cfg.AS.get("FRASER_version"), allow_missing=True)`'
#' type: script
#'---

Expand Down Expand Up @@ -66,4 +66,9 @@ for(type in psiTypes){
fds <- saveFraserDataSet(fds)
}
fds <- saveFraserDataSet(fds)

# remove previous hyper.done files and create new one
outdir <- dirname(snakemake@output$hyper)
prevFilterFiles <- grep("hyper(.*)done", list.files(outdir), value=TRUE)
unlink(file.path(outdir, prevFilterFiles))
file.create(snakemake@output$hyper)
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#' - workingDir: '`sm cfg.getProcessedDataDir() + "/aberrant_splicing/datasets/"`'
#' threads: 20
#' input:
#' - hyper: '`sm cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/hyper.done" `'
#' - hyper: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/hyper_{version}.done", version=cfg.AS.get("FRASER_version"), allow_missing=True)`'
#' output:
#' - fdsout: '`sm expand(cfg.getProcessedDataDir() +
#' "/aberrant_splicing/datasets/savedObjects/{dataset}/predictedMeans_{type}.h5", type=cfg.AS.getPsiTypeAssay(), allow_missing=True)`'
Expand Down Expand Up @@ -41,3 +41,11 @@ for(type in psiTypes){
fds <- saveFraserDataSet(fds)
}

# remove .h5 files from previous runs with other FRASER version
fdsDir <- dirname(snakemake@output$fdsout[1])
for(type in psiTypesNotUsed){
predMeansFile <- file.path(fdsDir, paste0("predictedMeans_", type, ".h5"))
if(file.exists(predMeansFile)){
unlink(predMeansFile)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ fds_input <- annotateIntronReferenceOverlap(fds_input, txdb)
# save fds
fds <- saveFraserDataSet(fds_input, dir=outputDir, name = paste(dataset, annotation, sep = '--'), rewrite = TRUE)

# remove .h5 files from previous runs with other FRASER version
fdsDir <- dirname(snakemake@output$fdsout[1])
for(type in psiTypesNotUsed){
predMeansFile <- file.path(fdsDir, paste0("predictedMeans_", type, ".h5"))
if(file.exists(predMeansFile)){
unlink(predMeansFile)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ for (type in psiTypes) {

fds <- saveFraserDataSet(fds)

# remove .h5 files from previous runs with other FRASER version
fdsDir <- dirname(snakemake@output$fdsout[1])
pvalFiles <- grep("p(.*)BetaBinomial_(.*).h5",
list.files(fdsDir),
value=TRUE)
for(type in psiTypesNotUsed){
pvalFilesType <- grep(type, pvalFiles, value=TRUE)
for(pFile in pvalFilesType){
unlink(file.path(fdsDir, pFile))
}
}
6 changes: 4 additions & 2 deletions drop/modules/aberrant-splicing-pipeline/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ h5disableFileLocking()
# set psiTypes to run based on preference in config.yaml
cfg <- yaml::read_yaml("config.yaml")
if(cfg$aberrantSplicing$FRASER_version == "FRASER2"){
psiTypes <- c("jaccard")
pseudocount(0.1)
psiTypes <- c("jaccard")
psiTypesNotUsed <- c("psi5", "psi3", "theta")
} else{
psiTypes <- c("psi5", "psi3", "theta")
pseudocount(1)
psiTypes <- c("psi5", "psi3", "theta")
psiTypesNotUsed <- c("jaccard")
}

0 comments on commit 54d157b

Please sign in to comment.