Skip to content
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

Speedup FRASER couting on Cluster #266

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ if(strandSpecific(fds) == 0){
genome <- getBSgenome(genomeAssembly)
}

# Copy to local tmp
bamFile <- bamFile(fds[, samples(fds) == sample_id])[[1]]
tmp_file <- file.path(snakemake@resources$tmpdir, paste0('split_counts_', sample_id, '.bam'))

message('Copy ', bamFile, ' to ', tmp_file)
file.copy(bamFile, tmp_file)
file.copy(paste0(bamFile, '.bai'), paste0(tmp_file, '.bai'))
bamFile(fds[, samples(fds) == sample_id]) <- tmp_file

# Count splitReads for a given sample id
sample_result <- countSplitReads(sampleID = sample_id,
fds = fds,
Expand All @@ -50,4 +59,8 @@ sample_result <- countSplitReads(sampleID = sample_id,
message(date(), ": ", dataset, ", ", sample_id,
" no. splice junctions (split counts) = ", length(sample_result))

# Reset bam file
bamFile(fds[, samples(fds) == sample_id]) <- bamFile
file.remove(tmp_file)

file.create(snakemake@output$done_sample_splitCounts)
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ sample_id <- snakemake@wildcards[["sample_id"]]
# Read splice site coordinates from RDS
spliceSiteCoords <- readRDS(snakemake@input$spliceSites)

# Copy to local tmp
bamFile <- bamFile(fds[, samples(fds) == sample_id])[[1]]
tmp_file <- file.path(snakemake@resources$tmpdir, paste0('nonsplit_counts_', sample_id, '.bam'))

message('Copy ', bamFile, ' to ', tmp_file)
file.copy(bamFile, tmp_file)
file.copy(paste0(bamFile, '.bai'), paste0(tmp_file, '.bai'))
bamFile(fds[, samples(fds) == sample_id]) <- tmp_file

# Count nonSplitReads for given sample id
sample_result <- countNonSplicedReads(sample_id,
splitCountRanges = NULL,
Expand All @@ -48,4 +57,8 @@ sample_result <- countNonSplicedReads(sample_id,
message(date(), ": ", dataset, ", ", sample_id,
" no. splice junctions (non split counts) = ", length(sample_result))

# Reset bam file
bamFile(fds[, samples(fds) == sample_id]) <- bamFile
file.remove(tmp_file)

file.create(snakemake@output$done_sample_nonSplitCounts)