Skip to content

Commit

Permalink
Merge branch 'main' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wxicu authored Nov 6, 2023
2 parents 49e8cb6 + c1e133a commit cdcda52
Show file tree
Hide file tree
Showing 20 changed files with 1,328 additions and 244 deletions.
6 changes: 1 addition & 5 deletions bin/HTODemux.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ assignment <- hashtag[[paste0(args$assay,"_classification")]]
assignment[[paste0(args$assay,"_classification")]][!assignment[[paste0(args$assay,"_classification")]] %in% c(donors, 'Negative')] <- "Doublet"


print("------------------- Following Files are saved ----------------------------")
print(paste0(args$assignmentOutHTOdemux, "_assignment_htodemux.csv"))
print(paste0(args$assignmentOutHTOdemux, "_classification_htodemux.csv"))
print(paste0(args$objectOutHTOdemux,".rds"))
print("params.csv")

write.csv(params, paste0(args$outputdir, "/params.csv"))
write.csv(assignment, paste0(args$outputdir, "/", args$assignmentOutHTOdemux, "_assignment_htodemux.csv"))
#write.csv(hashtag[[paste0(args$assay,"_classification")]], paste0(args$outputdir, "/", args$assignmentOutHTOdemux, "_assignment_htodemux.csv"))
Expand Down
6 changes: 1 addition & 5 deletions bin/MultiSeq.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ hashtag[[args$assay]]
print("-----------------------------------------------")
colnames(x = hashtag[[]])

#Save Results
print("------------------- Following Files are saved ----------------------------")
print(paste0(args$assignmentOutMulti, "_res.csv"))
print(paste0(args$objectOutMulti,".rds"))
print("params.csv")

write.csv(hashtag$MULTI_ID, paste0(args$outputdir, "/", args$assignmentOutMulti, "_res.csv"))
write.csv(params, paste0(args$outputdir, "/params.csv"))
saveRDS(hashtag, paste0(args$outputdir, "/", args$objectOutMulti, ".rds"))
34 changes: 28 additions & 6 deletions bin/bff.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,41 @@ if(as.logical(args$preprocess)){
counts <- Read10X(args$fileHto)
}

if(args$methodsForConsensus=="bff_raw" || args$methodsForConsensus=="bff_cluster" || args$methodsForConsensus=="combined_bff" || is.null(args$methodsForConsensus) )
substring_vector <- NULL
if (!is.null(args$methodsForConsensus)) {
consensus_methods = args$methodsForConsensus
substring_vector <- strsplit(consensus_methods, ",")[[1]]
}

perCell_args <- args$perCellSaturation
perCell <- ifelse(perCell_args == "null" || perCell_args == "Null", NULL, perCell_args)
<<<<<<< HEAD
<<<<<<< HEAD
print("---------------------")
print(perCell)
print("---------------------")
=======
print(perCell)

>>>>>>> c781241 (bff re-added problematic parameter)
=======
print("---------------------")
print(perCell)
print("---------------------")

if(args$methodsForConsensus=="bff_raw" || args$methodsForConsensus=="bff_cluster" || args$methodsForConsensus=="bff_raw,bff_cluster" || is.null(args$methodsForConsensus) )
#Only Bff in its different variations is available
if (args$methods == "bff_raw") {
print("Executing BFF raw")
cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_raw"), doTSNE = do_TSNE, doHeatmap = do_Heatmap, methodsForConsensus = args$methodsForConsensus,cellbarcodeWhitelist = args$cellbarcodeWhitelist, metricsFile= args$metricsFile, perCellSaturation= args$perCellSaturation, majorityConsensusThreshold = args$majorityConsensusThreshold, chemistry = args$chemistry, callerDisagreementThreshold = args$callerDisagreementThreshold )
cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_raw"), doTSNE = do_TSNE, doHeatmap = do_Heatmap, methodsForConsensus = substring_vector,cellbarcodeWhitelist = args$cellbarcodeWhitelist, metricsFile = args$metricsFile, perCellSaturation = args$perCellSaturation, majorityConsensusThreshold = args$majorityConsensusThreshold, chemistry = args$chemistry, callerDisagreementThreshold = args$callerDisagreementThreshold )
}else if (args$methods == "bff_cluster") {
print("Executing BFF cluster")
cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_cluster"), doTSNE = do_TSNE, doHeatmap = do_Heatmap)
#methodsForConsensus = args$methodsForConsensus,cellbarcodeWhitelist = args$cellbarcodeWhitelist, metricsFile= args$metricsFile, perCellSaturation= args$perCellSaturation, majorityConsensusThreshold = args$majorityConsensusThreshold, chemistry = args$chemistry, callerDisagreementThreshold = args$callerDisagreementThreshold
cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_cluster"), doTSNE = do_TSNE, doHeatmap = do_Heatmap,methodsForConsensus = substring_vector,cellbarcodeWhitelist = args$cellbarcodeWhitelist,metricsFile = args$metricsFile, perCellSaturation = args$perCellSaturation, majorityConsensusThreshold = args$majorityConsensusThreshold, chemistry = args$chemistry, callerDisagreementThreshold = args$callerDisagreementThreshold)
}else if (args$methods == "combined_bff") {
print("Executing BFF combined")
cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_raw", "bff_cluster") , doTSNE = do_TSNE, doHeatmap = do_Heatmap )
#methodsForConsensus = args$methodsForConsensus,cellbarcodeWhitelist = args$cellbarcodeWhitelist, metricsFile= args$metricsFile, perCellSaturation= args$perCellSaturation, majorityConsensusThreshold = args$majorityConsensusThreshold, chemistry = args$chemistry, callerDisagreementThreshold = args$callerDisagreementThreshold
cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_raw", "bff_cluster") , doTSNE = do_TSNE, doHeatmap = do_Heatmap,methodsForConsensus = substring_vector, cellbarcodeWhitelist = args$cellbarcodeWhitelist ,metricsFile = args$metricsFile, perCellSaturation = NULL, majorityConsensusThreshold = args$majorityConsensusThreshold )
#cell_hash_R_res <- GenerateCellHashingCalls(barcodeMatrix = counts, methods = c("bff_raw", "bff_cluster") , doTSNE = do_TSNE, doHeatmap = do_Heatmap,methodsForConsensus = substring_vector,cellbarcodeWhitelist = args$cellbarcodeWhitelist, metricsFile = args$metricsFile, perCellSaturation = NULL, majorityConsensusThreshold = args$majorityConsensusThreshold, chemistry = args$chemistry, callerDisagreementThreshold = args$callerDisagreementThreshold )

}else {
print("Method not available on the pipeline")
}else{
Expand Down
21 changes: 14 additions & 7 deletions bin/demuxem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import pegasus as pg
import demuxEM
import numpy as np
import scanpy as sc
import argparse
import pandas as pd
import pegasusio as io

parser = argparse.ArgumentParser(description='Parser for DemuxEM - Demultiplexing')
parser.add_argument('--rna_matrix_dir', help= 'cellranger output folder which contains raw RNA count matrix in mtx format.')
Expand All @@ -29,14 +31,16 @@
if __name__ == '__main__':
output_name = args.outputdir + "/" + args.objectOutDemuxem
# load input rna data
data = pg.read_input(args.rna_matrix_dir, modality="rna")
data.subset_data(modality_subset=['rna'])
data.concat_data() # in case of multi-organism mixing data
#data = io.read_input(args.rna_matrix_dir, modality="rna")
rna_data = sc.read_10x_mtx(args.rna_matrix_dir)
hashing_data = sc.read_10x_mtx(args.hto_matrix_dir,gex_only=False)
#data.subset_data(modality_subset=['rna'])
#data.concat_data() # in case of multi-organism mixing data
# load input hashing data
data.update(pg.read_input(args.hto_matrix_dir, modality="hashing"))
#data.update(io.read_input(args.hto_matrix_dir, modality="hashing"))
# Extract rna and hashing data
rna_data = data.get_data(modality="rna")
hashing_data = data.get_data(modality="hashing")
#rna_data = data.get_data(modality="rna")
#hashing_data = data.get_data(modality="hashing")
filter = ""
if args.filter_demuxem.lower() in ['true', 't', 'yes', 'y', '1']:
filter = True
Expand All @@ -47,6 +51,7 @@
# Filter the RNA matrix
rna_data.obs["n_genes"] = rna_data.X.getnnz(axis=1)
rna_data.obs["n_counts"] = rna_data.X.sum(axis=1).A1
#data.obs["n_counts"] = rna_data.X.sum(axis=1).A1
if(filter):
print("Filtering RNA matrix")
obs_index = np.logical_and.reduce(
Expand Down Expand Up @@ -85,8 +90,10 @@
title="{gene_name}: a gender-specific gene".format(gene_name=gene_name),
)
# output results
mudata = io.MultimodalData(rna_data)
mudata.update(io.read_input(args.hto_matrix_dir, modality="hashing"))
pg.write_output(demux_results, output_name + "_demux.zarr.zip")
pg.write_output(data, output_name + ".out.demuxEM.zarr.zip")
pg.write_output(mudata, output_name + ".out.demuxEM.zarr.zip")
print("\nSummary statistics:")
print("total\t{}".format(rna_data.shape[0]))
for name, value in rna_data.obs["demux_type"].value_counts().iteritems():
Expand Down
11 changes: 2 additions & 9 deletions bin/demuxmix.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#!/usr/bin/env Rscript
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager",repos = "http://cran.us.r-project.org")
is_demuxmix<-require("demuxmix")
if (!require("demuxmix", quietly = TRUE))
BiocManager::install("demuxmix")

library(Seurat)
library(demuxmix)
library(argparse)
Expand Down Expand Up @@ -36,11 +30,10 @@ args <- parser$parse_args()
if(as.logical(args$rna_available)){

umi <- Read10X(data.dir = args$fileUmi, gene.column=args$gene_col, strip.suffix = TRUE)
#umi <- readRDS(args$fileUmi)

}
counts <- Read10X(data.dir = args$fileHto, gene.column=args$gene_col, strip.suffix = TRUE)
#counts <- Read10X_h5(args$fileHto)
#counts <- readRDS(args$fileHto)


if(as.logical(args$rna_available)){
Argument <- c("fileUmi", "fileHto")
Expand Down
Loading

0 comments on commit cdcda52

Please sign in to comment.