Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add process for converting merged objects to AnnData #613

Merged
merged 6 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/merge_sces.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ option_list <- list(
the default is n_hvg = 2000"
),
make_option(
opt_str = c("--include_alt_exp"),
opt_str = c("--include_altexp"),
action = "store_true",
default = FALSE,
help = "Keep any altExp present in the merged object."
Expand Down Expand Up @@ -115,7 +115,7 @@ merged_sce <- scpcaTools::merge_sce_list(
batch_column = "library_id",
preserve_rowdata_cols = "gene_symbol",
cell_id_column = "cell_id",
include_alt_exp = include_alt_exp
include_altexp = opt$include_altexp
)


Expand Down
2 changes: 1 addition & 1 deletion config/containers.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Docker container images
SCPCATOOLS_CONTAINER = 'ghcr.io/alexslemonade/scpca-tools:v0.3.1'
SCPCATOOLS_CONTAINER = 'ghcr.io/alexslemonade/scpca-tools:edge'

ALEVINFRY_CONTAINER = 'quay.io/biocontainers/alevin-fry:0.7.0--h9f5acd7_1'
BCFTOOLS_CONTAINER = 'quay.io/biocontainers/bcftools:1.14--h88f3f91_0'
Expand Down
37 changes: 36 additions & 1 deletion merge.nf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ process merge_sce {
--input_sce_files "${input_sces}" \
--output_sce_file "${merged_sce_file}" \
--n_hvg ${params.num_hvg} \
"${has_adt ? "--include_alt_exp" : ''} \
${has_adt ? "--include_altexp" : ''} \
--threads ${task.cpus}
"""
stub:
Expand Down Expand Up @@ -85,6 +85,38 @@ process merge_report {
"""
}

process export_anndata{
container params.SCPCATOOLS_CONTAINER
label 'mem_16'
tag "${merge_group}"
publishDir "${params.results_dir}/merged/${merge_group}", mode: 'copy'
input:
tuple val(merge_group), val(has_adt), path(merged_sce_file)
output:
tuple val(merge_group), path("${merge_group}_merged_*.hdf5")
script:
rna_hdf5_file = "${merge_group}_merged_rna.hdf5"
feature_hdf5_file = "${merge_group}_merged_adt.hdf5"
"""
sce_to_anndata.R \
--input_sce_file ${merged_sce_file} \
--output_rna_h5 ${rna_hdf5_file} \
--output_feature_h5 ${feature_hdf5_file} \
${has_adt ? "--feature_name adt" : ''}

# move normalized counts to X in AnnData
move_counts_anndata.py --anndata_file ${rna_hdf5_file}
${has_adt ? "move_counts_anndata.py --anndata_file ${feature_hdf5_file}" : ''}
"""
stub:
rna_hdf5_file = "${merge_group}_merged_rna.hdf5"
feature_hdf5_file = "${merge_group}_merged_adt.hdf5"
"""
touch ${rna_hdf5_file}
${has_adt ? "touch ${feature_hdf5_file}" : ''}
"""
}

workflow {

// grab project ids to run
Expand Down Expand Up @@ -129,4 +161,7 @@ workflow {

// TODO: generate merge report
//merge_report(merge_sce.out, file(merge_template))

// export merged objects to AnnData
export_anndata(merge_sce.out)
}