Problem grouping technical replicates

Hello, I am trying to group technical replicates for further analysis. After I do alignment with FASTQ_ALIGN_STAR and mark duplicates with BAM_MARKDUPLICATES_PICARD, I would like to group the technical replicates but I am getting a strange error.

In trying to debug this, I have narrowed it to the following, consider this:

//Merge technical replicates of the same type
BAM_MARKDUPLICATES_PICARD.out.bam.map {
    meta, bam ->
    fmeta = meta
    // fmeta.newid = fmeta.sample
    [fmeta, bam] }.view()

And I get something correct, for example:

[[id:test1_replicate2_background, sample:test1, replicate:replicate2, type:background, single_end:false], /gpfs1/home/r/b/rbarrant/projects/nfcorePipelines/eclipseq/nf-core-eclipseq/work/7f/a8622e2be7ab71b95bb5fcba7a7690/test1_replicate2_background.bam]
[[id:test1_replicate1_background, sample:test1, replicate:replicate1, type:background, single_end:false], /gpfs1/home/r/b/rbarrant/projects/nfcorePipelines/eclipseq/nf-core-eclipseq/work/09/4f65ba22c124993a40b739e77b0100/test1_replicate1_background.bam]

But if I try to assign a new variable (just uncommenting the line above):

//Merge technical replicates of the same type
BAM_MARKDUPLICATES_PICARD.out.bam.map {
    meta, bam ->
    fmeta = meta
    fmeta.newid = fmeta.sample
    [fmeta, bam] }.view()

then I get an error:

[[id:test1_replicate1_background, sample:test1, replicate:replicate1, type:background, single_end:false, newid:test1], /gpfs1/home/r/b/rbarrant/projects/nfcorePipelines/eclipseq/nf-core-eclipseq/work/f7/adf10a510b2ff85d238468fd2981b0/test1_replicate1_background.bam]
ERROR ~ Unexpected error [NullPointerException]

– Check ‘.nextflow.log’ file for details

Do you have any suggestions on how I can debug this? I am out of ideas and I am new to groovy.

My (broken) pipeline is here.

Hey!

Can you give this a try:

//remove: fmeta = meta
//remove: fmeta.newid = fmeta.sample
meta + [ newid: meta.sample ]

There should be no need to reassign the metamap if you just want to add/change a field.

Thank you!This solved the problem. I have a related question but will ask separately.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.