Skip to content
Open
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
2 changes: 1 addition & 1 deletion modules/local/anndatar_convert.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ process ANNDATAR_CONVERT {
tuple val(meta), path(h5ad)

output:
tuple val(meta), path("${meta.id}_${meta.input_type}_matrix*.rds"), emit: rds
tuple val(meta), path("${meta.id}_${meta.input_type}_matrix*.rds"), emit: rds, optional: true
path "versions.yml" , emit: versions

when:
Expand Down
27 changes: 22 additions & 5 deletions modules/local/star_align.nf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ process STAR_ALIGN {
tuple val(meta), path('*d.out.bam') , emit: bam
tuple val(meta), path('*.Solo.out') , emit: counts
tuple val(meta), path ("*.Solo.out/Gene*/raw") , emit: raw_counts
tuple val(meta), path ("*.Solo.out/Gene*/filtered") , emit: filtered_counts
tuple val(meta), path ("*.Solo.out/Gene*/filtered") , emit: filtered_counts, optional: true
tuple val(meta), path ("*.Solo.out/Velocyto/velocyto_raw") , emit: raw_velocyto, optional:true
tuple val(meta), path ("*.Solo.out/Velocyto/velocyto_filtered"), emit: filtered_velocyto, optional:true
tuple val(meta), path('*Log.final.out') , emit: log_final
Expand Down Expand Up @@ -61,20 +61,37 @@ process STAR_ALIGN {
// separate forward from reverse pairs
def (forward, reverse) = reads.collate(2).transpose()
"""
if [[ $whitelist == *.gz ]]; then
gzip -cdf $whitelist > whitelist.uncompressed.txt
# If the whitelist was not provided
if [[ -z "$whitelist" ]]; then
echo "Whitelist file not provided." >&2
soloCBwhitelistArg=""
else
cp $whitelist whitelist.uncompressed.txt
if [[ "$whitelist" == *.gz ]]; then
gzip -cdf "$whitelist" > whitelist.uncompressed.txt
else
cp "$whitelist" whitelist.uncompressed.txt
fi
soloCBwhitelistArg="--soloCBwhitelist whitelist.uncompressed.txt"
echo "Whitelist file provided - $whitelist." >&2
fi

# If the SmartSeq protocol is used, set soloUMIdedup to NoDedup
if [[ "$protocol" == "SmartSeq" ]]; then
echo "SmartSeq protocol detected, setting --soloUMIdedup to NoDedup." >&2
soloUMIdedupArg="--soloUMIdedup NoDedup"
Comment on lines +79 to +81
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But hopefully the modifications are still useful even if users provide the appropriate parameters for SmartSeq3 data as well?

I was specifically refering to this statement. For SmartSeq3 UMI deduplication should be enabled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies, I should have realized that. I agree that the UMI deduplication should be able to enabled by the user. I will leave it to you whether that should be done by setting the protocol param (differentiating SmartSeq2 and SmartSeq3), or simply letting the UMI deduplication be a separate parameter. I can implement if you advise on your preferred approach.

else
soloUMIdedupArg=""
fi

STAR \\
--genomeDir $index \\
--readFilesIn ${reverse.join( "," )} ${forward.join( "," )} \\
--runThreadN $task.cpus \\
--outFileNamePrefix $prefix. \\
--soloCBwhitelist whitelist.uncompressed.txt \\
\$soloCBwhitelistArg \\
--soloType $protocol \\
--soloFeatures $star_feature \\
\$soloUMIdedupArg \\
$other_10x_parameters \\
$out_sam_type \\
$ignore_gtf \\
Expand Down
35 changes: 21 additions & 14 deletions modules/local/templates/anndatar_convert.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ library(SingleCellExperiment)

# read input
adata <- read_h5ad("${h5ad}")

# convert to Seurat
obj <- adata\$to_Seurat()

# save files
dir.create(file.path("$meta.id"), showWarnings = FALSE)
saveRDS(obj, file = "${meta.id}_${meta.input_type}_matrix.seurat.rds")

# convert to SingleCellExperiment
obj <- adata\$to_SingleCellExperiment()

# save files
dir.create(file.path("$meta.id"), showWarnings = FALSE)
saveRDS(obj, file = "${meta.id}_${meta.input_type}_matrix.sce.rds")
print("Read in ${h5ad} successfully.")
print(adata)

# If there is only 1 cell
if(adata\$shape()[1] == 1) {
print("The input file contains only one cell. Cannot create Seurat object.")
}else{
# convert to Seurat
obj <- adata\$to_Seurat()

# save files
dir.create(file.path("$meta.id"), showWarnings = FALSE)
saveRDS(obj, file = "${meta.id}_${meta.input_type}_matrix.seurat.rds")

# convert to SingleCellExperiment
obj <- adata\$to_SingleCellExperiment()

# save files
dir.create(file.path("$meta.id"), showWarnings = FALSE)
saveRDS(obj, file = "${meta.id}_${meta.input_type}_matrix.sce.rds")
}

#
# save versions file
Expand Down