@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix CommandLineBinding: <https://w3id.org/cwl/cwl#CommandLineBinding/> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/> .
@prefix Workflow: <https://w3id.org/cwl/cwl#Workflow/> .
@prefix cwl:   <https://w3id.org/cwl/cwl#> .
@prefix sld:   <https://w3id.org/cwl/salad#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ResourceRequirement: <https://w3id.org/cwl/cwl#ResourceRequirement/> .
@prefix CommandOutputBinding: <https://w3id.org/cwl/cwl#CommandOutputBinding/> .
@prefix ns2:   <https://> .
@prefix ns1:   <http://commonwl.org/cwltool#> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot/in_file>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/result_dir> ;
        cwl:valueFrom  "${for(var i in self[0].listing){\n  var file = self[0].listing[i];\n  if (file.basename == self[1] + \"-Doublets_prediction.pdf\"){\n    return file;}\n    }\n}\n" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file/in_file>
        rdfs:comment  "Input file to rename" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/cluster_file>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_cluster> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/align_qc_rds>
        rdfs:comment  "Align QC file frm D3b 10X alignment workflow" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_ram>
        rdfs:comment  "Amount in GB ram to resrve for scdblfinder" ;
        sld:default   16 ;
        sld:type      xsd:int , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name>
        rdfs:comment  "used as prefix for finding fastqs to analyze, e.g. 1k_PBMCs_TotalSeq_B_3p_LT_antibody if the names of the underlying fastqs are of the form 1k_PBMCs_TotalSeq_B_3p_LT_antibody_S1_L001_I1_001.fastq.gz, one per input fastq in the same order" ;
        sld:type      xsd:string .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots/in_file>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/marker_plots> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/cpus>
        rdfs:comment  "Num CPUs for Seurat parallization" ;
        sld:default   8 ;
        sld:type      xsd:int , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/seurat_raw_object>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_raw_rds> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_doublets>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets/renamed_file> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file/renamed_file>
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.out_filename)" ] ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.out_filename)" ] ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.out_filename)" ] ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.out_filename)" ] ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.out_filename)" ] ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.out_filename)" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/filtered_rds>
        rdfs:comment       "Seurat RDS filtered with mRNA contamination and doublets removed" ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "*.rds" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/ram> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/seurat_raw_object> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/result_dir> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filtered_rds>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/filtered_rds> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file/out_filename>
        rdfs:comment  "New file name for in_file" ;
        sld:type      xsd:string .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots/out_filename>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> ;
        cwl:valueFrom  "$(self).soupx.rplots.pdf" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/output_basename>
        rdfs:comment      "Output file prefix filtered Seurat output" ;
        cwl:inputBinding  [ CommandLineBinding:position  2 ;
                            CommandLineBinding:prefix    "--output_basename"
                          ] ;
        sld:type          xsd:string , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_matrix_raw>
        rdfs:comment  "h5 raw_feature_bc_matrix file from cellranger or equivalent" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/soupx_rds>
        rdfs:comment      "RDS object produced by SoupX" ;
        cwl:inputBinding  [ CommandLineBinding:position  2 ;
                            CommandLineBinding:prefix    "--soupx_rds"
                          ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_plot>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot/renamed_file> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/results_dir>
        rdfs:comment      "Name of dir to create to store outputs" ;
        cwl:inputBinding  [ CommandLineBinding:position  1 ;
                            CommandLineBinding:prefix    "--results_dir"
                          ] ;
        sld:default       "./" ;
        sld:type          xsd:string , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "Run custom QC on 10X output" ;
        ns1:original_cwlVersion  "v1.2" ;
        cwl:arguments            ( [ CommandLineBinding:position    1 ;
                                     CommandLineBinding:shellQuote  false ;
                                     cwl:valueFrom                  "\"rmarkdown::render('scDblFinder.Rmd', clean = TRUE,\n      params=list(results_dir='.', \n                  data_path='$(inputs.seurat_raw_object.path)', \n                  sample_name='$(inputs.sample_name)',\n                  cpus=$(inputs.cpus),\n                  ram=$(inputs.ram)\n                  ))\""
                                   ]
                                 ) ;
        cwl:baseCommand          ( "Rscript" "-e" ) ;
        cwl:cwlVersion           cwl:v1.2 ;
        cwl:inputs               <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/ram> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/cpus> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/seurat_raw_object> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/result_dir> ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "pgc-images.sbgenomics.com/d3b-bixu/scdblfinder:v1.12.0"
                                 ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "---\ntitle: \"ScDblFinder filtering with recoverDoublets - `r params$sample_name`\"\nauthor: 'Antonia Chroni <chronia@chop.edu> for D3B'\ndate: \"`r Sys.Date()`\"\noutput:\n  html_notebook:\n    toc: TRUE\n    toc_float: TRUE\nparams:\n  data_path: './' # path to the directory with the `seurat_obj_raw.rds` file from the `seurat_alignment_qc.Rmd` script\n  results_dir: './' # path to dir to save all output files\n  sample_name: \"test\"   # name of the sample in the library\n  cpus: 4\n  ram: 64\n  log_file: NULL\n---\n\n# Information about this notebook\nThis script used the [ScDblFinder](https://bioconductor.org/packages/devel/bioc/vignettes/scDblFinder/inst/doc/scDblFinder.html) method for identifying doublets in single-cell data. \n\n# Usage\nTo run the Rscript from the command line sequentially, use:\n\n```\nRscript -e \"rmarkdown::render('scDblFinder.Rmd', clean = TRUE,\n      params=list(results_dir = '/Users/chronia/CHOP/GitHub/kf-dev-single-cell-rna/scripts/example/', \n                  data_path = '/Users/chronia/CHOP/GitHub/kf-dev-single-cell-rna/scripts/example/test.seurat_obj_raw.rds',\n                  sample_name = 'test',\n                  cpus=8,\n                  ram=16\n))\"\n```\n\n# Set up\n\n```{r load-library, echo=TRUE}\nsuppressPackageStartupMessages({\n  library(scDblFinder)\n  library(Seurat)\n  library(scater)\n  library(future)\n  library(tidyverse)\n  library(grid)\n})\n\n```\n\n# Directories and paths to file Inputs/Outputs\n\n```{r set-dir-and-file-names, echo=TRUE}\nattach(params)\n\n# evaluate Seurat R expressions asynchronously when possible (such as ScaleData) using future package\nplan(\"multisession\", workers = cpus)\noptions(future.globals.maxSize = ram * 1000 * 1024^2) # for 64 Gb RAM\n\n#create results_dir\nresults_dir <-\n  file.path(results_dir)\nif (!dir.exists(results_dir)) {\n  dir.create(results_dir)\n}\n\n\n# File path to doublets directory\ndoublets_dir <- file.path(paste0(results_dir,\"/scDblFinder-\", sample_name, \"/\"))\nif (!dir.exists(doublets_dir)) {\n  dir.create(doublets_dir)\n}\n```\n\n\n# Read raw seurat_objs \nWe will load the raw seurat object as generated in the `seurat_alignment_qc.Rmd` script.\nWe will run dimensionality reductions and convert to single cell experiments.\n\n\n```{r process-seurat-obj-convert-to-sce, echo=TRUE}\nseurat_obj_raw <- readRDS(data_path)\nDefaultAssay(seurat_obj_raw) <- \"RNA\"\n\n# Make this reproducible as UMAP algorithm is not deterministic\nset.seed(1234)\n# Normalize, find variable features and scale data\nseurat_obj <- seurat_obj_raw %>%\n  NormalizeData() %>%\n  FindVariableFeatures(selection.method = \"vst\", nfeatures = 2000) %>%\n  ScaleData() \n\n# Run dim_reductions\nseurat_obj <- RunPCA(seurat_obj, features = VariableFeatures(object = seurat_obj), npcs=30) %>%\n                    RunUMAP(dims = 1:20, n.neighbors=20L, reduction.name = \"umap\", reduction.key = \"UMAP_\", verbose = FALSE)\n\nseurat_obj <- as.SingleCellExperiment(seurat_obj)\n\n# Save sce\n# saveRDS(seurat_obj, file = paste0(results_dir, \"/\", \"seurat_obj_sce.rds\"))\n```\n\n# Run scDblFinder \n\n`scDblFinder function` is used to identify cells that are doublets based on cluster-based generation of artificial doublets. \nWe will save the cells that need to be filtered based on scDblFinder analysis in a separate table.\n\n\n```{r run-recoverDoublets, echo=TRUE}\n# Run scDblFinder\nbp <- BiocParallel::MulticoreParam(4, RNGseed=1234)\nBiocParallel::bpstart(bp)\nset.seed(1234)\nseurat_obj  <- scDblFinder(seurat_obj, clusters = TRUE, BPPARAM = bp)\nBiocParallel::bpstop(bp)\n\n# Estimate singlets and doublets in the library\nsinglets_doublets_number <- print(table(seurat_obj$scDblFinder.class)) %>%\n  as.data.frame() %>% \n  mutate(prediction = Var1,\n         count = Freq) %>% \n  dplyr::select(-Var1, -Freq)\n\n# Estimate pct of doublets in the library\ndoublets_pct_library <- print(table(seurat_obj$scDblFinder.class)[2]/(table(seurat_obj$scDblFinder.class)[1]+table(seurat_obj$scDblFinder.class)[2])*100)\n\n####### Create metrics per library #######\ndoublets_metrics <- data.frame(matrix(ncol = 4, nrow = 1))\ncolnames(doublets_metrics) <- c(\"sample_name\", \"singlet\", \"doublet\", \"doublets_pct_library\")#provide column names\n\ndoublets_metrics$sample_name <- sample_name\n\ndoublets_metrics$singlet <- as.numeric(singlets_doublets_number %>% \n                                         filter(prediction == \"singlet\") %>% \n                                         dplyr::select(-prediction) %>% \n                                         mutate(singlet = count) %>% \n                                         dplyr::select(-count))\n\ndoublets_metrics$doublet <- as.numeric(singlets_doublets_number %>% \n                                         filter(prediction == \"doublet\") %>% \n                                         dplyr::select(-prediction) %>% \n                                         mutate(doublet = count) %>% \n                                         dplyr::select(-count))\n\ndoublets_metrics$doublets_pct_library <- doublets_pct_library\n\nreadr::write_tsv(doublets_metrics, paste0(doublets_dir, \"doublets_metrics_\", sample_name, \".tsv\"))\n\n####################################################\n\ndoublets <- seurat_obj@colData[,str_detect(colnames(seurat_obj@colData), \"scDblFinder\")] %>% \n  as.data.frame() %>% \n  tibble::rownames_to_column(\"cell\") %>% \n  mutate(sample_name = sample_name,\n         is_doublet = case_when(grepl(\"doublet\", scDblFinder.class) ~ \"TRUE\",\n                                grepl(\"singlet\", scDblFinder.class) ~ \"FALSE\",\n                                TRUE ~ scDblFinder.class))\n\n# Save table with all predictions\nreadr::write_tsv(doublets, paste0(doublets_dir, \"doublets_\", sample_name, \".tsv\"))\n    \n# Cells that we need to filter from the final object\ndoublets.to.filter <- subset(doublets, doublets$scDblFinder.class == \"doublet\") \n\ndoublets_number <- print(table(seurat_obj$scDblFinder.class))\n\n# Save table with cells to be filtered\n# readr::write_tsv(doublets.to.filter, paste0(doublets_dir, \"doublets_to_filter_\", sample_name,\".tsv\"))\n\n# Convert sce list into seurat list\nseurat_obj_with_doublets <- as.Seurat(seurat_obj, \n                                      counts = \"counts\", # includes spliced and unspliced transcripts\n                                      data = \"logcounts\") # derived from the counts matrix\n  \n# Save seurat_obj with doublets predictions in the metadata\nsaveRDS(seurat_obj_with_doublets, paste0(doublets_dir, \"seurat_obj_with_doublets_\", sample_name,\".rds\"))\n```\n\nThere are `r singlets_doublets_number` singlets and doublets, respectively. \nDoublets represent `r doublets_pct_library` % of cells in the whole library.\n\n\n# Plot the Doublets predictions on the UMAP\n\n```{r plot-Doublets, fig.width = 15, fig.height = 4, fig.fullwidth = TRUE, echo=TRUE}\nprint(\"Doublets predictions\")\n  \nfname <- paste0(doublets_dir, sample_name, \"-Doublets_prediction.pdf\")\nprint(fname)\nprint(gridExtra::grid.arrange(\n  plotUMAP(seurat_obj, colour_by=\"scDblFinder.cluster\", point_size = 0.1) + ggtitle(\"scDblFinder clusters\"),\n  plotUMAP(seurat_obj, colour_by=\"scDblFinder.score\", point_size = 0.1) + ggtitle(\"Doublets score\"),\n  plotUMAP(seurat_obj, colour_by=\"scDblFinder.class\", point_size = 0.1) + ggtitle(\"Doublets prediction\"),\n  ncol = 3,\n  top = paste0(sample_name, \"-Doublets prediction\")))\n\npdf(file = fname, width = 15, height = 4)\n\nprint(gridExtra::grid.arrange(\n  plotUMAP(seurat_obj, colour_by=\"scDblFinder.cluster\", point_size = 0.1) + ggtitle(\"scDblFinder clusters\"),\n  plotUMAP(seurat_obj, colour_by=\"scDblFinder.score\", point_size = 0.1) + ggtitle(\"Doublets score\"),\n  plotUMAP(seurat_obj, colour_by=\"scDblFinder.class\", point_size = 0.1) + ggtitle(\"Doublets prediction\"),\n  ncol = 3,\n  top = paste0(sample_name, \"-Doublets prediction\")))\n\ndev.off()\n```\n\n\n```{r}\nsessionInfo()\n```\n\n" ;
                                                  cwl:entryname  "scDblFinder.Rmd"
                                                ]
                                 ] ;
        cwl:requirements         [ a                             cwl:ResourceRequirement ;
                                   ResourceRequirement:coresMin  "$(inputs.cpus)" ;
                                   ResourceRequirement:ramMin    "${ return inputs.ram * 1000 }"
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/sample_name>
        rdfs:comment      "Name of this sample" ;
        cwl:inputBinding  [ CommandLineBinding:position  1 ;
                            CommandLineBinding:prefix    "--sample_name"
                          ] ;
        sld:type          xsd:string .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary/out_filename>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> ;
        cwl:valueFrom  "$(self).scDblFinder.summary_metrics.tsv" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/scdblfinder_tsv>
        rdfs:comment      "TSV file with doublet information produced by scDblFinder" ;
        cwl:inputBinding  [ CommandLineBinding:position  2 ;
                            CommandLineBinding:prefix    "--scdblfinder_tsv"
                          ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/sample_name>
        sld:type  xsd:string .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/ram>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_ram> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/rplots>
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.results_dir == \"./\" ? inputs.sample_name + \".soupx.plots.pdf\" : inputs.results_dir + \"/\" + inputs.sample_name + \".soupx.plots.pdf\")\n" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets/out_filename>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> ;
        cwl:valueFrom  "$(self).scDblFinder.doublets.tsv" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots/in_file>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/rplots> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots/out_filename> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots/in_file> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots/renamed_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/output_basename> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/scdblfinder_tsv> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/seurat_qc_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/seurat_raw_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/soupx_rds> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/filtered_summary> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/filtered_rds> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots/in_file> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots/out_filename> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots/renamed_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/sample_name>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds/in_file>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/decontaminated_matrix_rds> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/decontaminated_matrix_rds>
        rdfs:comment       "rds containing decontaminated matrix" ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.results_dir == \"./\" ? inputs.sample_name + \".soupx.rds\" : inputs.results_dir + \"/\" + inputs.sample_name + \".soupx.rds\")\n" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "Run SoupX on 10x output to remove mRNA contamination https://github.com/constantAmateur/SoupX" ;
        ns1:original_cwlVersion  "v1.2" ;
        cwl:arguments            ( [ CommandLineBinding:position    0 ;
                                     CommandLineBinding:shellQuote  false ;
                                     cwl:valueFrom                  "run_soupX.R"
                                   ]
                                 ) ;
        cwl:baseCommand          ( "Rscript" ) ;
        cwl:cwlVersion           cwl:v1.2 ;
        cwl:inputs               <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/results_dir> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/cluster_file> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/filtered_matrix> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/raw_matrix> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/sample_name> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/decontaminated_matrix_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/marker_plots> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/rplots> ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "# R script for mRNA decontamination of 10X single-cell data using SoupX\n\noptions(error = traceback)\n\nsuppressMessages(library(optparse))\nsuppressMessages(library(SoupX))\nsuppressMessages(library(Seurat))\nsuppressMessages(library(Matrix))\nsuppressMessages(library(dplyr))\nsuppressMessages(library(ggplot2))\n\n#process inputs\noption_list <- list(\n  make_option(\n    opt_str = \"--raw\",\n    type = \"character\",\n    help = \"Path to h5 file containing raw matrix from Cell Ranger count\"\n  ),\n  make_option(\n    opt_str = \"--filtered\",\n    type = \"character\",\n    help = \"Path to h5 file containing filtered matrix from Cell Ranger count\"\n  ),\n  make_option(\n    opt_str = \"--cluster\",\n    type = \"character\",\n    help = \"Path to csv file containing barcodes and cluster id from Cell Ranger count\"\n  ),\n  make_option(\n    opt_str = \"--sample_name\",\n    type = \"character\",\n    help = \"Name associated with this sample\"\n  ),\n  make_option(\n    opt_str = \"--results_dir\",\n    type = \"character\",\n    help = \"output dir to put results\",\n    default=\"./\"\n  )\n)\n\n#parse options\nopts <- parse_args(OptionParser(option_list = option_list))\nraw <- opts$raw\nfiltered <- opts$filtered\nclusters_file <- opts$cluster\nsample_name <- opts$sample_name\nresults_dir <- opts$results_dir\ndir.create(results_dir)\n\n# load 10X data and convert to Soup Channel (object SoupX uses for analysis)\nfiltered_matrix <- Read10X_h5(filtered, use.names = TRUE)\nraw_matrix <- Read10X_h5(raw, use.names = TRUE)\n\n############################################################################\n# SoupX will use default pdf settings, set output file name to be more useful\npdf(file = file.path(results_dir, paste0(sample_name, \".soupx.plots.pdf\")))\n\n# Make a Seurat object from the sparce matrix\nseurat_obj  <- CreateSeuratObject(counts = filtered_matrix)\n\n# If cluster file available\nif (!is.null(clusters_file)) {\n  write(\"Clusters file exists!\", stderr())\n  clusters <- read.csv(clusters_file)\n  mDat <- data.frame(clusters=clusters$Cluster, row.names=clusters$Barcode)\n  sc <- SoupChannel(raw_matrix, filtered_matrix, mDat)\n} else {\n  write(\"Clusters file does not exist. Calculate clusters by using Seurat.\", stderr())\n  # Make a “SoupChannel”, the object needed to run SoupX\n  sc  <- SoupChannel(raw_matrix, filtered_matrix)\n  \n  # Normalize, find variable features and scale the data\n  seurat_obj <- NormalizeData(seurat_obj, normalization.method = \"LogNormalize\", scale.factor = 10000, verbose = TRUE) %>% \n    FindVariableFeatures(selection.method = \"vst\", nfeatures = 2000) %>%\n    ScaleData() \n  seurat_obj <- RunPCA(seurat_obj, verbose = FALSE)\n    \n  ## Run jackstraw to score pcs\n  seurat_obj <- JackStraw(seurat_obj, num.replicate = 100)\n  seurat_obj <- ScoreJackStraw(seurat_obj, dims = 1:20)\n  \n  # Define parameters for clustering\n  pc_cut = 0.05\n  num_pcs = 10\n  res_value = 0.5\n  \n  # Determine number of pcs to use for clustering\n  scores <- JS(object = seurat_obj[[\"pca\"]], slot = \"overall\")\n  auto_pcs <- length(which(scores[, \"Score\"] <= pc_cut))\n  if (num_pcs < auto_pcs) {\n    num_pcs <- auto_pcs\n  }\n  seurat_obj <- RunUMAP(seurat_obj, dims = 1:num_pcs, verbose = FALSE)\n  seurat_obj <- FindNeighbors(seurat_obj, dims = 1:num_pcs, verbose = FALSE)\n  # Estimate clusters\n  seurat_obj <- FindClusters(seurat_obj, resolution = res_value, verbose = TRUE)\n  \n  # After clustering is obtained, it can be added to the channel using setClusters. \n  # setDR is useful for visualizations.\n  meta <- seurat_obj@meta.data\n  umap <- seurat_obj@reductions$umap@cell.embeddings\n  sc  <- setClusters(sc, setNames(meta$seurat_clusters, rownames(meta)))\n  sc  <- setDR(sc, umap)\n}\n\n\n######################################################################################\n######################################################################################\n# With defined clusters, run the main SoupX function, calculating ambient RNA profile.\n######################################################################################\n######################################################################################\n\n# Estimate contamination fraction rho\n# The posterior distribution is calculated using a Poisson likelihood with a gamma distribution prior, parametrised by its mean priorRho and standard deviation priorRhoStdDev. The dotted line in the above plot shows the prior distribution. The default parameters have been calibrated to be fairly non-specific \n# with a slight preference towards values of rho in the 0% to 10% range which is most commonly seen for fresh (i.e. not nuclear) single cell experiments.\n# The default values place only a very weak constraint, as can be seen by setting a uniform prior.\nsc <- autoEstCont(sc) #priorRhoStdDev = 0.3\n\n# To visualize the distribution of expression (relative to what would be expected were each cell pure background) across all cells in the data set. \n# When no geneset is provided, the function will try and guess which genes might be useful.\nplotMarkerDistribution(sc)\n\n# Save the plot\nggsave(filename = paste0(sample_name, \".soupx.plotMarkerDistribution.pdf\"),\n       path = results_dir, \n       width = 6, \n       height = 5, \n       device = \"pdf\", \n       useDingbats = FALSE)\n\n# Correcting expression profile\n# This will contain a corrected matrix to be used in place of the original table of counts in downstream analyses.\n# use roundToInt option to make sure we output integer matrix.\nout <- adjustCounts(sc, roundToInt = TRUE) \n\n# Let's save corrected matrix as a separate assay\nseurat_obj[[\"RNA_SoupX\"]] <- CreateAssayObject(counts = seurat_obj@assays$RNA@counts)\nseurat_obj@assays$RNA@counts <- out\n\n# Setup assay for seurat object for next steps to the one with corrected gene counts\nDefaultAssay(seurat_obj) <- \"RNA_SoupX\"\n\n# Integrating with downstream tools\n# Of course, the next thing you'll want to do is to load this corrected expression matrix into some downstream analysis tool and further analyse the data.\n\ncolnames(out) = gsub('-1$', '', colnames(out))\ncolnames(out) = paste(sample_name, colnames(out), sep=\":\")\n\nsaveRDS(out, file.path(results_dir, paste0(sample_name, \".soupx.rds\")))\n" ;
                                                  cwl:entryname  "run_soupX.R"
                                                ]
                                 ] ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "pgc-images.sbgenomics.com/d3b-bixu/soupx_r:1.6.2"
                                 ] .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/cluster_file>
        rdfs:comment      "CSV file clusters produced by Cell Ranger count. If other input or not available, leave out and tool will cluster" ;
        cwl:inputBinding  [ CommandLineBinding:position  1 ;
                            CommandLineBinding:prefix    "--cluster"
                          ] ;
        sld:type          cwl:File , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/seurat_qc_rds>
        rdfs:comment      "qc RDS object produced by Seurat QC" ;
        cwl:inputBinding  [ CommandLineBinding:position  2 ;
                            CommandLineBinding:prefix    "--seurat_qc_rds"
                          ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_matrix_filtered>
        rdfs:comment  "h5 filtered_feature_bc_matrix file from cellranger or equivalent" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/seurat_raw_object>
        rdfs:comment  "Seurat RDS from align/qc workflow" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "Tool to rename files" ;
        ns1:original_cwlVersion  "v1.2" ;
        cwl:baseCommand          ( "echo" "done" ) ;
        cwl:baseCommand          ( "echo" "done" ) ;
        cwl:baseCommand          ( "echo" "done" ) ;
        cwl:baseCommand          ( "echo" "done" ) ;
        cwl:baseCommand          ( "echo" "done" ) ;
        cwl:baseCommand          ( "echo" "done" ) ;
        cwl:cwlVersion           cwl:v1.2 ;
        cwl:inputs               <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file/in_file> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file/out_filename> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl#rename_file/renamed_file> ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "$(inputs.in_file)" ;
                                                  cwl:entryname  "$(inputs.out_filename)"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "$(inputs.in_file)" ;
                                                  cwl:entryname  "$(inputs.out_filename)"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "$(inputs.in_file)" ;
                                                  cwl:entryname  "$(inputs.out_filename)"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "$(inputs.in_file)" ;
                                                  cwl:entryname  "$(inputs.out_filename)"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "$(inputs.in_file)" ;
                                                  cwl:entryname  "$(inputs.out_filename)"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "$(inputs.in_file)" ;
                                                  cwl:entryname  "$(inputs.out_filename)"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds/out_filename>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> ;
        cwl:valueFrom  "$(self).soupx.decontaminated_matrix.rds" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_cluster>
        rdfs:comment  "clusters.csv file from cellranger or equivalent if available" ;
        sld:type      cwl:File , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/seurat_qc_rds>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/align_qc_rds> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots/out_filename>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> ;
        cwl:valueFrom  "$(self).soupx.plotMarkerDistribution.pdf" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets/in_file> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets/out_filename> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets/renamed_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/raw_matrix>
        rdfs:comment      "H5 file raw matrix produced by Cell Ranger count" ;
        cwl:inputBinding  [ CommandLineBinding:position  1 ;
                            CommandLineBinding:prefix    "--raw"
                          ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/scdblfinder_tsv>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/result_dir> ;
        cwl:valueFrom  "${for(var i in self[0].listing){\n  var file = self[0].listing[i];\n  if (file.basename == \"doublets_\" + self[1] + \".tsv\"){\n    return file;\n    }\n  }\n}\n" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds/out_filename> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds/in_file> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds/renamed_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/filtered_summary>
        rdfs:comment       "Seurat TSV filter summary" ;
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "*.tsv" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot/out_filename> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot/in_file> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot/renamed_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/filtered_matrix>
        rdfs:comment      "H5 file filtered matrix produced by Cell Ranger count" ;
        cwl:inputBinding  [ CommandLineBinding:position  1 ;
                            CommandLineBinding:prefix    "--filtered"
                          ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/raw_matrix>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_matrix_raw> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filtered_summary>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/filtered_summary> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx_marker_plots>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots/renamed_file> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets/in_file>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/result_dir> ;
        cwl:valueFrom  "${for(var i in self[0].listing){\n  var file = self[0].listing[i];\n  if (file.basename == \"doublets_\" + self[1] + \".tsv\"){\n    return file;\n    }\n  }\n}\n" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl#soupx/marker_plots>
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.results_dir == \"./\" ? inputs.sample_name + \".soupx.plotMarkerDistribution.pdf\" : inputs.results_dir + \"/\" + inputs.sample_name + \".soupx.plotMarkerDistribution.pdf\")\n" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/soupx_rds>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/decontaminated_matrix_rds> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_raw_rds>
        rdfs:comment  "Seurat raw rds file from D3b 10X alignment workflow" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary/in_file> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary/out_filename> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary/renamed_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/rename_file.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/ram>
        rdfs:comment  "Ram in GB for task" ;
        sld:default   16 ;
        sld:type      xsd:int , sld:null .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/seurat_raw_rds>
        rdfs:comment      "raw RDS object produced by Seurat QC" ;
        cwl:inputBinding  [ CommandLineBinding:position  2 ;
                            CommandLineBinding:prefix    "--seurat_raw_rds"
                          ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx_rplots>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots/renamed_file> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/filtered_matrix>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_matrix_filtered> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary/in_file>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder/result_dir> ;
        cwl:valueFrom  "${for(var i in self[0].listing){\n  var file = self[0].listing[i];\n  if (file.basename == \"doublets_metrics_\" + self[1] + \".tsv\"){\n    return file;\n    }\n  }\n}\n" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot/out_filename>
        cwl:source     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> ;
        cwl:valueFrom  "$(self).scDblFinder.prediction.pdf" .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/sample_name>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename>
        rdfs:comment  "basename used to name output files" ;
        sld:type      xsd:string .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "Filter Seurat QC RDS file using a SoupX RDS and Scrublet CSV" ;
        ns1:original_cwlVersion  "v1.2" ;
        cwl:baseCommand          ( "Rscript" "seurat_filter.R" ) ;
        cwl:cwlVersion           cwl:v1.2 ;
        cwl:inputs               <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/seurat_raw_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/output_basename> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/seurat_qc_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/soupx_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/scdblfinder_tsv> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/filtered_summary> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/seurat_filter.cwl#seurat_filter/filtered_rds> ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "satijalab/seurat:4.3.0"
                                 ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "#!/usr/bin/env Rscript\n\nif(!suppressWarnings(require(optparse))){\n    install.packages(\"optparse\", quiet=TRUE)\n    library(optparse)\n}\nlibrary(Seurat)\n\n#process inputs\noption_list <- list(\n  make_option(\n    opt_str = \"--seurat_raw_rds\",\n    type = \"character\",\n    help = \"Raw RDS object produced by Seurat QC\"\n  ),\n  make_option(\n    opt_str = \"--seurat_qc_rds\",\n    type = \"character\",\n    help = \"qc RDS object produced by Seurat QC\"\n  ),\n  make_option(\n    opt_str = \"--soupx_rds\",\n    type = \"character\",\n    help = \"RDS object produced by SoupX\"\n  ),\n  make_option(\n    opt_str = \"--scdblfinder_tsv\",\n    type = \"character\",\n    help = \"TSV file with doublet information produced by scDblFinder\"\n  ),\n  make_option(\n    opt_str = \"--output_basename\",\n    type = \"character\",\n    default = \"seurat_qc.filtered\",\n    help = \"Name for filtered Seurat RDS output\"\n  )\n)\n\nopts <- parse_args(OptionParser(option_list = option_list), print_help_and_exit = TRUE)\nif (is.null(opts$seurat_qc_rds) | is.null(opts$seurat_qc_rds) | is.null(opts$soupx_rds)) {\n    write(\"\\n\\nseurat_qc_rds, soupx_rds, and scdblfinder_tsv must be provided! One or more are missing!\", stderr())\n    quit(status=1)\n}\noutput_basename <- opts$output_basename\nseurat_raw_rds <- opts$seurat_raw_rds\nseurat_qc_rds <- opts$seurat_qc_rds\nsoupx_rds <- opts$soupx_rds\nscdblfinder_tsv <- opts$scdblfinder_tsv\n\nwrite(\"\\n\\nLoading Files...\", stderr())\nseurat_raw_obj <- readRDS(seurat_raw_rds)\nseurat_qc_obj <- readRDS(seurat_qc_rds)\nsoupx_obj <- readRDS(soupx_rds)\nscDblFinder_df <- read.csv(scdblfinder_tsv, sep = \"\\t\", header = TRUE, row.names=1)\nwrite(\"Done loading files, getting aligned cell count\", stderr())\n# Create and update a filter summary file\n\nfilter_summary = paste0(output_basename, \".refinement_stats.tsv\")\nwrite(\"Filter step\\tNumber of to remove\\tNumber of cells\", file=filter_summary)\n\nnum_align <- ncol(seurat_raw_obj)\nwrite(paste(\"Alignment\", \"NA\", num_align, sep=\"\\t\"), file=filter_summary, append = TRUE)\n\nwrite(\"Filtering Seurat Cells...\", stderr())\nwrite(\"...Beginning QC Filtration...\", stderr())\nnum_qc_filtered = ncol(seurat_qc_obj)\nwrite(paste(\"Seurat QC\", (num_align - num_qc_filtered), num_qc_filtered, sep=\"\\t\"), file=filter_summary, append = TRUE)\n# Report mRNA\nfilter_cells <- colnames(seurat_qc_obj)[which(!(colnames(seurat_qc_obj) %in% colnames(soupx_obj)))] # Get Seurat cells not found in SoupX\nif (num_qc_filtered == 0) {\n    write(\"......No Seurat cells identified as mRNA contaminated. No cells removed...\", stderr())\n} else {\n    write(\"......Cells found in Seurat were identified by SoupX as mRNA contaminated! Removing the following cells from Seurat:\", stderr())\n    cat(filter_cells, sep = \"\\n\", file = stderr())\n}\n\nwrite(\"...Beginning SoupX Filtration...\", stderr())\n# Remove Cells Not Found in Both Seurat and SoupX\ncommon_cells <- Reduce(intersect, list(colnames(seurat_qc_obj),colnames(soupx_obj)))\nseurat_qc_obj <- subset(seurat_qc_obj, cells = common_cells)\nsoupx_obj <- soupx_obj[,common_cells]\n# write(paste(\"SoupX contamination\", ncol(seurat_qc_obj), sep=\"\\t\"), file=filter_summary, append = TRUE)\nwrite(\"...SoupX Filtration Complete...\", stderr())\n\n# Create new RNA_filter assay\nwrite(\"...Adding RNA_filter assay to Seurat...\", stderr())\nseurat_qc_obj[[\"RNA_filter\"]] <- CreateAssayObject(counts = soupx_obj)\nDefaultAssay(seurat_qc_obj) <- \"RNA_filter\"  # make new filter the default for future steps\nwrite(\"...RNA_filter assay added...\", stderr())\n\n# Remove scDblFinder-Identified Doublets from Seurat\nwrite(\"...Beginning scDblFinder Filtration...\", stderr())\nseurat_qc_obj <- AddMetaData(seurat_qc_obj, scDblFinder_df)\n# Report Doublets\ndoublet_cells <- colnames(seurat_qc_obj)[which(seurat_qc_obj@meta.data$is_doublet == TRUE)]\ndbl_ct = length(doublet_cells)\nif (dbl_ct == 0) {\n    write(\"......No Seurat cells identified as doublets. No cells removed...\", stderr())\n} else {\n    write(\"......Cells found in Seurat were identified by scDblFinder as doublets! Removing the following cells from Seurat:\", stderr())\n    cat(doublet_cells, sep = \"\\n\", file = stderr())\n}\n\nseurat_filtered_obj <- subset(seurat_qc_obj, cells = WhichCells(seurat_qc_obj, expression = is_doublet==FALSE))\nwrite(\"...scDblFinder Filtration Complete...\", stderr())\nwrite(\"Seurat Filtering Complete!\", stderr())\n\nwrite(paste(\"scDblFinder doublet\", dbl_ct, ncol(seurat_filtered_obj), sep=\"\\t\"), file=filter_summary, append = TRUE)\n\nwrite(\"Saving Filtered Seurat Object...\", stderr())\nsaveRDS(seurat_filtered_obj, paste0(output_basename, \".refined.rds\"))\nwrite(\"Program Complete!\", stderr())\n" ;
                                                  cwl:entryname  "seurat_filter.R"
                                                ]
                                 ] .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx>
        cwl:in   <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/filtered_matrix> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/raw_matrix> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/cluster_file> ;
        cwl:out  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/decontaminated_matrix_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/rplots> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx/marker_plots> ;
        cwl:run  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/soupx.cwl> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/seurat_raw_rds>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_raw_rds> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx_rds>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds/renamed_file> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter/output_basename>
        cwl:source  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/tools/scdblfinder.cwl#scdblfinder-rmd/result_dir>
        rdfs:comment       "Dir containing all files that were generated by the notebook" ;
        cwl:outputBinding  [ CommandOutputBinding:glob  "scDblFinder-$(inputs.sample_name)" ;
                             cwl:loadListing            "deep_listing"
                           ] ;
        sld:type           cwl:Directory .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_summary>
        cwl:outputSource  <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary/renamed_file> ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement>
        a                              cwl:Workflow ;
        rdfs:comment                   "# 10X Refinement Workflow\n\nThe workflow script that runs the tools is `workflows/kf_single_cell_10x_refinement.cwl`\n\n[SoupX](https://github.com/constantAmateur/SoupX) is used for subtraction of the RNA background.\n[scDblFinder](https://github.com/plger/scDblFinder) is used to score and predict doublets.\nDecontaminated outputs are aggregated using the [Seurat](https://satijalab.org/seurat/) R package from the Satija lab at the New York Genome Center.\nOriginal workflow design heavily contributed to by Erin Reichenbee of DBHi.\n\n## Software\n\n- SoupX 1.6.2\n- scDblFinder 1.12.0\n- Seurat 4.3.0.1\n- SeuratObject 4.1.3\n- tidyverse docker base 4.2.3\n\n## Inputs\n### multi-step\n - `output_basename`: basename used to name output files\n - `sample_name`: used as prefix for finding fastqs to analyze, e.g. 1k_PBMCs_TotalSeq_B_3p_LT_antibody if the names of the underlying fastqs are of the form 1k_PBMCs_TotalSeq_B_3p_LT_antibody_S1_L001_I1_001.fastq.gz, one per input fastq in the same order\n### soupX\n - `counts_matrix_raw`: h5 format raw feature matrix file from Cellranger or equivalent\n - `counts_matrix_filtered`: h5 format filtered feature matrix file from Cellranger or equivalent\n - `counts_cluster`: CSV containing cluster information from Cellranger or equivalent if available\n### scDblFinder\n - `align_qc_rds`: Align QC file frm D3b 10X alignment workflow\n - `seurat_raw_rds`: Seurat raw rds file from D3b 10X alignment workflow\n\n### Outputs\n- `soupx_rplots`: PDF R plot made by soupX\n- `soupx_rds`: R object with SoupX results\n- `scdblfinder_plot`: PDF cluster plots generated by scDblFinder\n- `scdblfinder_doublets`: TSV containing scoring matrix with doublets marked by scDblFinder\n- `scdblfinder_summary`: Summary stats of number and percent of doublets in library\n- `seurat_filtered_rds`: RDS file containing filtered 10X data based on Seurat QC (align workflow) SoupX and scDblFinder results \n- `seurat_filtered_summary`: TSV file summarizing number of cells removed at each step, if relevant\n" ;
        rdfs:label                     "KFDRC Single Cell RNA 10x Refinement Workflow" ;
        ns1:original_cwlVersion        "v1.2" ;
        ns2:sevenbridges.comlicense    "Apache License 2.0" ;
        ns2:sevenbridges.compublisher  "KFDRC" ;
        Workflow:steps                 <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filter> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_doublets> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_summary> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_soupx_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_rplots> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_scdblfinder_plot> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/rename_marker_plots> ;
        cwl:cwlVersion                 cwl:v1.2 ;
        cwl:hints                      [ a  ns2:sevenbridges.commaxNumberOfParallelInstances ] ;
        cwl:inputs                     <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/output_basename> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_raw_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/align_qc_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/sample_name> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_matrix_filtered> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_cluster> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/counts_matrix_raw> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_ram> ;
        cwl:outputs                    <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx_rplots> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filtered_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/seurat_filtered_summary> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx_marker_plots> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_summary> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/soupx_rds> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_plot> , <https://w3id.org/cwl/view/git/2cfe9d988a9f845905949f55ca96d12cc1e0a7a2/workflows/kf_single_cell_10x_refinement.cwl#kf-single-cell-10x-refinement/scdblfinder_doublets> ;
        cwl:requirements               [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements               [ a  cwl:StepInputExpressionRequirement ] ;
        cwl:requirements               [ a  cwl:ScatterFeatureRequirement ] .
