Skip to content
Snippets Groups Projects
Commit 66ed13b5 authored by Adrian Zimmer's avatar Adrian Zimmer
Browse files

Dockerize kallisto_collect

parent cde2abc0
No related branches found
No related tags found
No related merge requests found
...@@ -8,14 +8,6 @@ cd /Users/dominikbrilhaus/gitlab_dataplant/samplearc_rnaseq/runs/kallisto_collec ...@@ -8,14 +8,6 @@ cd /Users/dominikbrilhaus/gitlab_dataplant/samplearc_rnaseq/runs/kallisto_collec
## Let it flow ## Let it flow
```bash ```bash
### store arc root (two levels up from here) as variable
arc_root=$(echo ${PWD%/*/*})
### replace arc root line in yml (specific to the machine from where this is run)
### not sure, if this works on linux...
sed -i '' "s|^arc_root:.*|arc_root: $arc_root|g" kallisto_collect.yml
### run with cwltool ### run with cwltool
cwltool ../../workflows/kallisto_collect.cwl kallisto_collect.yml cwltool --enable-dev run.cwl kallisto_collect.yml
``` ```
cores: 1 cores: 1
r_script: in_kallisto_results:
class: Directory
path: ../kallisto_sleuth/out
in_metadata_file:
class: File class: File
path: ../../workflows/kallisto_collect.R path: ../merged_isa_metadata/merged_isa.tsv
in_kallisto_results: "runs/no_CWL_yet/kallisto_sleuth/run1/01_kallisto_results"
in_metadata_file: "runs/merged_isa_metadata/merged_isa.tsv"
in_metadata_sample: "Sample.Name.2" in_metadata_sample: "Sample.Name.2"
in_metadata_factor: "Factor..Photosynthesis.mode." in_metadata_factor: "Factor..Photosynthesis.mode."
out_folder: runs/kallisto_collect out_folder: out
arc_root: /Users/dominikbrilhaus/gitlab_dataplant/samplearc_rnaseq \ No newline at end of file
\ No newline at end of file
#!/usr/bin/env cwl-runner
cwlVersion: v1.2.0-dev1
class: Workflow
inputs:
in_kallisto_results:
type: Directory
in_metadata_file:
type: File
in_metadata_sample:
type: string
in_metadata_factor:
type: string
out_folder:
type: string
outputs:
out_dir:
type:
type: array
items: Directory
outputSource: kallisto_collect/outdir
steps:
kallisto_collect:
run: ../../workflows/kallisto_collect/workflow.cwl
in:
in_kallisto_results: in_kallisto_results
in_metadata_file: in_metadata_file
in_metadata_sample: in_metadata_sample
in_metadata_factor: in_metadata_factor
out_folder: out_folder
out: [outdir]
...@@ -11,9 +11,9 @@ outputs: ...@@ -11,9 +11,9 @@ outputs:
type: type:
type: array type: array
items: Directory items: Directory
outputSource: kallisto_quant/outdir outputSource: kallisto_sleuth/outdir
steps: steps:
kallisto_quant: kallisto_sleuth:
run: ../../workflows/kallisto_sleuth/workflow.cwl run: ../../workflows/kallisto_sleuth/workflow.cwl
in: in:
in_sleuth: in_sleuth in_sleuth: in_sleuth
......
ö#!/usr/bin/env Rscript #!/usr/bin/env Rscript
################################################ ################################################
#### CWL-independent tests #### CWL-independent tests
...@@ -25,31 +25,30 @@ library(jsonlite) ...@@ -25,31 +25,30 @@ library(jsonlite)
args <- commandArgs(trailingOnly = T) args <- commandArgs(trailingOnly = T)
arc_root <- args[1] in_kallisto_results <- args[1]
in_kallisto_results <- args[2] in_metadata_file <- args[2]
in_metadata_file <- args[3] in_metadata_sample <- args[3]
in_metadata_sample <- args[4] in_metadata_factor <- args[4]
in_metadata_factor <- args[5] out_folder <- args[5]
out_folder <- args[6]
################################################ ################################################
#### If it does not exist, create out dir #### If it does not exist, create out dir
################################################ ################################################
dir.create(paste(arc_root, out_folder, sep = "/"), recursive = T, showWarnings = F) dir.create(out_folder, recursive = T, showWarnings = F)
################################################ ################################################
#### Read ISA sample metadata #### Read ISA sample metadata
################################################ ################################################
samples <- read.table(file = paste(arc_root, in_metadata_file, sep = "/"), sep = "\t") samples <- read.table(file = in_metadata_file, sep = "\t")
################################################ ################################################
#### Read Kallisto results #### Read Kallisto results
################################################ ################################################
base_dir <- paste(arc_root, in_kallisto_results, sep = "/") base_dir <- in_kallisto_results
# A list of paths to the kallisto results indexed by the sample IDs is collated with # A list of paths to the kallisto results indexed by the sample IDs is collated with
kal_dirs <- dir(base_dir, full.names = T) ## Sleuth requires full paths kal_dirs <- dir(base_dir, full.names = T) ## Sleuth requires full paths
...@@ -67,7 +66,7 @@ s2c <- merge(s2c, path_df, by = "out_name") ...@@ -67,7 +66,7 @@ s2c <- merge(s2c, path_df, by = "out_name")
so <- sleuth_prep(s2c, full_model = ~condition, num_cores = 1) so <- sleuth_prep(s2c, full_model = ~condition, num_cores = 1)
save(so, file = paste(arc_root, out_folder, "kallisto_sleuthObject.RData", sep = "/")) save(so, file = paste(out_folder, "kallisto_sleuthObject.RData", sep = "/"))
################################################ ################################################
...@@ -78,13 +77,13 @@ save(so, file = paste(arc_root, out_folder, "kallisto_sleuthObject.RData", sep = ...@@ -78,13 +77,13 @@ save(so, file = paste(arc_root, out_folder, "kallisto_sleuthObject.RData", sep =
expression_data <- kallisto_table(so) expression_data <- kallisto_table(so)
## write to file ## write to file
write.csv(expression_data, paste(arc_root, out_folder, "/kallisto_df.csv", sep = "/"), row.names = F) write.csv(expression_data, paste(out_folder, "/kallisto_df.csv", sep = "/"), row.names = F)
## as tpm matrix (gene x sample) ## as tpm matrix (gene x sample)
tpm_table <- pivot_wider(expression_data, id_cols = target_id, names_from = sample, values_from = tpm) tpm_table <- pivot_wider(expression_data, id_cols = target_id, names_from = sample, values_from = tpm)
## write to file ## write to file
write.csv(tpm_table, paste(arc_root, out_folder, "/kallisto_tpmMatrix.csv", sep = "/"), row.names = F) write.csv(tpm_table, paste(out_folder, "/kallisto_tpmMatrix.csv", sep = "/"), row.names = F)
################################################ ################################################
#### Summarize mapping stats #### Summarize mapping stats
...@@ -99,4 +98,4 @@ for (i in dir(kal_dirs, pattern = ".json", full.names = T)) ...@@ -99,4 +98,4 @@ for (i in dir(kal_dirs, pattern = ".json", full.names = T))
mapping_stats <- rbind(mapping_stats, z) mapping_stats <- rbind(mapping_stats, z)
} }
write.csv(mapping_stats, paste(arc_root, out_folder, "/kallisto_mappingStats.csv", sep = "/"), row.names = F) write.csv(mapping_stats, paste(out_folder, "/kallisto_mappingStats.csv", sep = "/"), row.names = F)
#!/usr/bin/env cwl-runner #!/usr/bin/env cwl-runner
cwlVersion: v1.2 cwlVersion: v1.2.0-dev1
class: CommandLineTool class: CommandLineTool
hints:
DockerRequirement:
dockerPull: zimmera95/rnaseq:latest
requirements:
- class: InitialWorkDirRequirement
listing:
- class: File
location: kallisto_collect.R
arguments:
- position: 0
valueFrom: kallisto_collect.R
inputs: inputs:
- id: r_script
type: File
inputBinding:
position: 0
- id: arc_root
type: string
inputBinding:
position: 1
- id: in_kallisto_results - id: in_kallisto_results
type: string type: Directory
inputBinding: inputBinding:
position: 2 position: 1
- id: in_metadata_file - id: in_metadata_file
type: string type: File
inputBinding: inputBinding:
position: 3 position: 2
- id: in_metadata_sample - id: in_metadata_sample
type: string type: string
inputBinding: inputBinding:
position: 4 position: 3
- id: in_metadata_factor - id: in_metadata_factor
type: string type: string
inputBinding: inputBinding:
position: 5 position: 4
- id: out_folder - id: out_folder
type: string type: string
inputBinding: inputBinding:
position: 6 position: 5
outputs: outputs:
- id: outdir - id: outdir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment