-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from nf-core/81-call-empty-droplets
Fix issue 81, "call empty droplets"
- Loading branch information
Showing
37 changed files
with
682 additions
and
174 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env Rscript | ||
library("DropletUtils") | ||
library("Matrix") | ||
|
||
args <- commandArgs(trailingOnly=TRUE) | ||
|
||
fn_mtx <- args[1] | ||
fn_barcodes <- args[2] | ||
fn_genes <- args[3] | ||
outdir <- args[4] | ||
aligner <- args[5] | ||
|
||
# Read matrix/barcodes/genes | ||
genes <- read.table(fn_genes,sep='\t') | ||
barcodes <- read.table(fn_barcodes,sep='\t') | ||
mtx <- readMM(fn_mtx) | ||
|
||
get_name <- function(file) { | ||
name <- as.character(basename(file)) | ||
name <- gsub('\\.gz$', '', name) | ||
return(name) | ||
} | ||
|
||
# transpose matrices when required | ||
# based on code of 'mtx_to_seurat.R', only the data from kallisto and alevin would require transposition | ||
print("Only kallisto and alevin have transposed matrices.") | ||
if (aligner %in% c( "kallisto", "alevin" )) { | ||
is_transposed <- TRUE | ||
mtx<-t(mtx) | ||
} else { | ||
is_transposed <- FALSE | ||
} | ||
|
||
|
||
# Call empty drops | ||
e.out <- emptyDrops(mtx) | ||
is.cell <- e.out$FDR <= 0.01 | ||
|
||
# Slice matrix and barcodes | ||
mtx_filtered <-mtx[,which(is.cell),drop=FALSE] | ||
barcodes_filtered<-barcodes[which(is.cell),] | ||
|
||
# If matrix was transposed early, need to transpose back | ||
if (is_transposed){ | ||
mtx_filtered<-t(mtx_filtered) | ||
print('Transposing back matrix.') | ||
} | ||
|
||
# Write output | ||
writeMM(mtx_filtered,file.path(outdir,get_name(fn_mtx))) | ||
write.table(barcodes_filtered,file=file.path(outdir,get_name(fn_barcodes)),col.names=FALSE,row.names=FALSE,sep='\t',quote=FALSE) | ||
write.table(genes,file=file.path(outdir,get_name(fn_genes)),col.names=FALSE,row.names=FALSE,sep='\t',quote=FALSE) |
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
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
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
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
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
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
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
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
Oops, something went wrong.