Commit ee609792 authored by Gervaise Henry's avatar Gervaise Henry 🤠
Browse files

Add downstreamViz (seurat) generation

parent 83890557
Pipeline #7866 passed with stages
in 18 minutes and 59 seconds
......@@ -88,6 +88,7 @@ filename_checkScript = Channel.fromPath("$baseDir/scripts/filename_check.sh")
generate_versionsScript = Channel.fromPath("$baseDir/scripts/generate_versions.py")
generate_referencesScript = Channel.fromPath("$baseDir/scripts/generate_references.py")
versions_pythonScript = Channel.fromPath("$baseDir/scripts/versions_python.sh")
downstream_vizScript = Channel.fromPath("$baseDir/scripts/downstream_viz.r")
// Define report files
multiqcConf = "${baseDir}/configs/multiqc_config.yaml"
......@@ -200,7 +201,8 @@ process count211 {
chemistryParam211
output:
file("**/outs/**") into outPaths211
set sample, file("**/outs/**") into outPaths211
set sample, file("**/outs/filtered_*/**"), file("**/outs/analysis/clustering/graphclust/**"), file("**/outs/analysis/clustering/kmeans_2_clusters/**"), file("**/outs/analysis/clustering/kmeans_3_clusters/**"), file("**/outs/analysis/clustering/kmeans_4_clusters/**"), file("**/outs/analysis/clustering/kmeans_5_clusters/**"), file("**/outs/analysis/clustering/kmeans_6_clusters/**"), file("**/outs/analysis/clustering/kmeans_7_clusters/**"), file("**/outs/analysis/clustering/kmeans_8_clusters/**"), file("**/outs/analysis/clustering/kmeans_9_clusters/**"), file("**/outs/analysis/clustering/kmeans_10_clusters/**"), file("**/outs/analysis/pca/**"), file("**/outs/analysis/tsne/**") into filteredOut211
file("*_metrics_summary.tsv") into metricsSummary211
when:
......@@ -247,7 +249,8 @@ process count302 {
chemistryParam302
output:
file("**/outs/**") into outPaths302
set sample, file("**/outs/**") into outPaths302
set sample, file("**/outs/filtered_*/**"), file("**/outs/analysis/clustering/graphclust/**"), file("**/outs/analysis/clustering/kmeans_2_clusters/**"), file("**/outs/analysis/clustering/kmeans_3_clusters/**"), file("**/outs/analysis/clustering/kmeans_4_clusters/**"), file("**/outs/analysis/clustering/kmeans_5_clusters/**"), file("**/outs/analysis/clustering/kmeans_6_clusters/**"), file("**/outs/analysis/clustering/kmeans_7_clusters/**"), file("**/outs/analysis/clustering/kmeans_8_clusters/**"), file("**/outs/analysis/clustering/kmeans_9_clusters/**"), file("**/outs/analysis/clustering/kmeans_10_clusters/**"), file("**/outs/analysis/pca/**"), file("**/outs/analysis/tsne/**") into filteredOut302
file("*_metrics_summary.tsv") into metricsSummary302
when:
......@@ -293,7 +296,8 @@ process count310 {
chemistryParam310
output:
file("**/outs/**") into outPaths310
set sample, file("**/outs/**") into outPaths310
set sample, file("**/outs/filtered_*/**"), file("**/outs/analysis/clustering/graphclust/**"), file("**/outs/analysis/clustering/kmeans_2_clusters/**"), file("**/outs/analysis/clustering/kmeans_3_clusters/**"), file("**/outs/analysis/clustering/kmeans_4_clusters/**"), file("**/outs/analysis/clustering/kmeans_5_clusters/**"), file("**/outs/analysis/clustering/kmeans_6_clusters/**"), file("**/outs/analysis/clustering/kmeans_7_clusters/**"), file("**/outs/analysis/clustering/kmeans_8_clusters/**"), file("**/outs/analysis/clustering/kmeans_9_clusters/**"), file("**/outs/analysis/clustering/kmeans_10_clusters/**"), file("**/outs/analysis/pca/**"), file("**/outs/analysis/tsne/**"), file("**/outs/analysis/umap/**") into filteredOut310
file("*_metrics_summary.tsv") into metricsSummary310
when:
......@@ -339,7 +343,8 @@ process count400 {
chemistryParam400
output:
file("**/outs/**") into outPaths400
set file("**/outs/**") into outPaths400
set sample, file("**/outs/filtered_*/**"), file("**/outs/analysis/clustering/graphclust/**"), file("**/outs/analysis/clustering/kmeans_2_clusters/**"), file("**/outs/analysis/clustering/kmeans_3_clusters/**"), file("**/outs/analysis/clustering/kmeans_4_clusters/**"), file("**/outs/analysis/clustering/kmeans_5_clusters/**"), file("**/outs/analysis/clustering/kmeans_6_clusters/**"), file("**/outs/analysis/clustering/kmeans_7_clusters/**"), file("**/outs/analysis/clustering/kmeans_8_clusters/**"), file("**/outs/analysis/clustering/kmeans_9_clusters/**"), file("**/outs/analysis/clustering/kmeans_10_clusters/**"), file("**/outs/analysis/pca/**"), file("**/outs/analysis/tsne/**"), file("**/outs/analysis/umap/**") into filteredOut400
file("*_metrics_summary.tsv") into metricsSummary400
when:
......@@ -423,3 +428,29 @@ process multiqc {
multiqc -c ${multiqcConf} .
"""
}
// Collect all outputs reguardless of cellranger version
filteredOut = filteredOut211.mix(filteredOut302, filteredOut310, filteredOut400)
/*
* downstreamViz: create files for downstream use (eg. R Seurat object)
*/
process downstreamViz {
tag "${sample}"
publishDir "${outDir}/${task.process}", mode: 'copy'
module 'seurat/3.0.0'
input:
file downstream_vizScript
set sample, file("filtered/*"), file("clustering/graphclust/*"), file("clustering/kmeans_2_clusters/*"), file("clustering/kmeans_3_clusters/*"), file("clustering/kmeans_4_clusters/*"), file("clustering/kmeans_5_clusters/*"), file("clustering/kmeans_6_clusters/*"), file("clustering/kmeans_7_clusters/*"), file("clustering/kmeans_8_clusters/*"), file("clustering/kmeans_9_clusters/*"), file("clustering/kmeans_10_clusters/*"), file("pca/*"), file("tsne/*"), file("umap/*") from filteredOut
output:
file "*.rds" into seuratPaths
script:
"""
hostname
ulimit -a
seurat-Rscript downstream_viz.r --sample ${sample} --cellrangerVersion ${version}
"""
}
library(optparse)
library(Seurat)
option_list=list(
make_option("--sample",default="sample1",action="store",type='character',help="sample"),
make_option("--cellrangerVersion",default="4.0.0",action="store",type='character',help="cellranger Version")
)
opt=parse_args(OptionParser(option_list=option_list))
rm(option_list)
data <- Read10X(data.dir="filtered/")
data <- CreateSeuratObject(counts=data)
dimReductions <- c("pca","tsne")
if (opt$cellrangerVersion!="2.1.1" && opt$cellrangerVersion!="3.0.2"){
dimReductions <- c(dimReductions,"umap")
}
for (i in dimReductions){
if (i=="tsne"){
lab <- "tSNE"
} else {
lab <- toupper(i)
}
projection <- read.csv(paste0(i,"/projection.csv"),row.names=1)
rownames(projection) <- gsub("-.","",rownames(projection))
data[[i]] <- CreateDimReducObject(embeddings=as.matrix(projection),key=paste0(lab,"_"),assay="RNA")
}
clust <- c("graphclust",paste0("kmeans_",2:10,"_clusters"))
for (i in clust){
clusters <- read.csv(paste0("clustering/",i,"/clusters.csv"),row.names=1)
rownames(clusters) <- gsub("-.","",rownames(clusters))
data[[i]] <- clusters
data@meta.data <- data@meta.data[,colnames(data@meta.data)!="orig.ident"]
}
saveRDS(data,paste0(opt$sample,".rds"))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment