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

Various MultiQC issues: FastQC sections for raw and trimmed reads // umi-tools dedup and extraction plots, custom content styling. #1308

Merged
merged 21 commits into from
Jul 12, 2024

Conversation

MatthiasZepper
Copy link
Member

@MatthiasZepper MatthiasZepper commented May 29, 2024

This draft PR comprises my current progress towards fixing issue #1303.

It does modify the publishDir directives in the FastQC module config such that the reports are consistently published in ${params.outdir}/fastqc/raw and ${params.outdir}/fastqc/trim regardless of the chosen trimmer (TrimGalore!, Fastp), and adapts the custom MultiQC config of the pipeline accordingly.

This is, however, not sufficient to fix the issue, because recent versions of MultiQC have a bug that prevents running the same module twice. There are still separate entries and columns in the General Statistics table, but the modules are not shown in the report and navigation bar:

MultiQC 1.23dev, 1.22, 1.21 MultiQC 1.18
Sidebar in MultiQC 1.23dev MultiQC 1.18
Screenshot of Navbar 1.23dev Screenshot of Navbar 1.18

For both screenshots, I ran MultiQC on the output directory of a test profile run of this pipeline using the custom profile in workflows/rnaseq/assets/multiqc/multiqc_config.yml.

It should be stressed that the FastQC module itself works in modern versions, because if the custom config is omitted, it is also shown. But forcing the module to run twice via a custom config seemingly breaks it. Only in theGeneral Statisticstable, it still works like a charm. Thus, the reports are parsed, but the module output is not displayed in the report.

MultiQC 1.23 General Statistics Table

Further issues

In the course of troubleshooting this issue, I discovered more issues that need to be tackled. Help would be greatly appreciated with those:

Inconsistent naming of FastQC output:

For FastP, the file names are retained before and after trimming:

fastqc
├── raw
│   ├── RAP1_IAA_30M_REP1_1_fastqc.html
│   ├── RAP1_IAA_30M_REP1_1_fastqc.zip
│   ├── RAP1_IAA_30M_REP1_2_fastqc.html
│   ├── RAP1_IAA_30M_REP1_2_fastqc.zip
│   ├── RAP1_UNINDUCED_REP1_fastqc.html
│   ├── RAP1_UNINDUCED_REP1_fastqc.zip
│   ├── RAP1_UNINDUCED_REP2_fastqc.html
│   ├── RAP1_UNINDUCED_REP2_fastqc.zip
│   ├── WT_REP1_1_fastqc.html
│   ├── WT_REP1_1_fastqc.zip
│   ├── WT_REP1_2_fastqc.html
│   ├── WT_REP1_2_fastqc.zip
│   ├── WT_REP2_1_fastqc.html
│   ├── WT_REP2_1_fastqc.zip
│   ├── WT_REP2_2_fastqc.html
│   └── WT_REP2_2_fastqc.zip
└── trim
   ├── RAP1_IAA_30M_REP1_1_fastqc.html
   ├── RAP1_IAA_30M_REP1_1_fastqc.zip
   ├── RAP1_IAA_30M_REP1_2_fastqc.html
   ├── RAP1_IAA_30M_REP1_2_fastqc.zip
   ├── RAP1_UNINDUCED_REP1_fastqc.html
   ├── RAP1_UNINDUCED_REP1_fastqc.zip
   ├── RAP1_UNINDUCED_REP2_fastqc.html
   ├── RAP1_UNINDUCED_REP2_fastqc.zip
   ├── WT_REP1_1_fastqc.html
   ├── WT_REP1_1_fastqc.zip
   ├── WT_REP1_2_fastqc.html
   ├── WT_REP1_2_fastqc.zip
   ├── WT_REP2_1_fastqc.html
   ├── WT_REP2_1_fastqc.zip
   ├── WT_REP2_2_fastqc.html
   └── WT_REP2_2_fastqc.zip

For TrimGalore!, the RAP1_UNINDUCED samples are renamed with a trimmed suffix and the others receive _val1_ and _val2_ suffixes.

fastqc
├── raw
│   ├── RAP1_IAA_30M_REP1_1_fastqc.html
│   ├── RAP1_IAA_30M_REP1_1_fastqc.zip
│   ├── RAP1_IAA_30M_REP1_2_fastqc.html
│   ├── RAP1_IAA_30M_REP1_2_fastqc.zip
│   ├── RAP1_UNINDUCED_REP1_fastqc.html
│   ├── RAP1_UNINDUCED_REP1_fastqc.zip
│   ├── RAP1_UNINDUCED_REP2_fastqc.html
│   ├── RAP1_UNINDUCED_REP2_fastqc.zip
│   ├── WT_REP1_1_fastqc.html
│   ├── WT_REP1_1_fastqc.zip
│   ├── WT_REP1_2_fastqc.html
│   ├── WT_REP1_2_fastqc.zip
│   ├── WT_REP2_1_fastqc.html
│   ├── WT_REP2_1_fastqc.zip
│   ├── WT_REP2_2_fastqc.html
│   └── WT_REP2_2_fastqc.zip
└── trim
    ├── RAP1_IAA_30M_REP1_1_val_1_fastqc.html
    ├── RAP1_IAA_30M_REP1_1_val_1_fastqc.zip
    ├── RAP1_IAA_30M_REP1_2_val_2_fastqc.html
    ├── RAP1_IAA_30M_REP1_2_val_2_fastqc.zip
    ├── RAP1_UNINDUCED_REP1_trimmed_fastqc.html
    ├── RAP1_UNINDUCED_REP1_trimmed_fastqc.zip
    ├── RAP1_UNINDUCED_REP2_trimmed_fastqc.html
    ├── RAP1_UNINDUCED_REP2_trimmed_fastqc.zip
    ├── WT_REP1_1_val_1_fastqc.html
    ├── WT_REP1_1_val_1_fastqc.zip
    ├── WT_REP1_2_val_2_fastqc.html
    ├── WT_REP1_2_val_2_fastqc.zip
    ├── WT_REP2_1_val_1_fastqc.html
    ├── WT_REP2_1_val_1_fastqc.zip
    ├── WT_REP2_2_val_2_fastqc.html
    └── WT_REP2_2_val_2_fastqc.zip

Unfortunately, I have no idea why. I have quadruplechecked the publishDir directives and can't explain. Help and inspiration needed!

Duplicate column is actually shown in the General Statistics table (FIXED!)

According to the config, the duplicate column from FastQC should be hidden in the General Statistics table. However, it is shown. Might be another MultiQC bug or that I just stared myself blind.

# Don't show % Dups in the General Stats table (we have this from Picard)
table_columns_visible:
  fastqc:
    percent_duplicates: False

umi-tools dedup stats not shown (Fixed)

According to our current master / dev branch config, the umi_tools module is not run. Seeing this, I believed that would be an easy fix for #1277 and added the module in the config. However, no reports are shown. Either the module is broken or the deduplication stats are not channelled to MultiQC. In either way, also no quick solution in sight here.

PR checklist

  • This comment contains a description of changes (with reason).
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added a new tool - have you followed the pipeline conventions in the contribution docs
  • If necessary, also make a PR on the nf-core/rnaseq branch on the nf-core/test-datasets repository.
  • Make sure your code lints (nf-core lint).
  • Ensure the test suite passes (nextflow run . -profile test,docker --outdir <OUTDIR>).
  • Check for unexpected warnings in debug mode (nextflow run . -profile debug,test,docker --outdir <OUTDIR>).
  • Usage Documentation in docs/usage.md is updated.
  • Output Documentation in docs/output.md is updated.
  • CHANGELOG.md is updated.
  • README.md is updated (including new tool citations and authors/contributors).

Copy link

github-actions bot commented May 29, 2024

nf-core lint overall result: Passed ✅ ⚠️

Posted for pipeline commit 1c75669

+| ✅ 173 tests passed       |+
#| ❔   9 tests were ignored |#
!| ❗   7 tests had warnings |!

❗ Test warnings:

  • files_exist - File not found: assets/multiqc_config.yml
  • files_exist - File not found: .github/workflows/awstest.yml
  • files_exist - File not found: .github/workflows/awsfulltest.yml
  • pipeline_todos - TODO string in main.nf: Optionally add in-text citation tools to this list.
  • pipeline_todos - TODO string in main.nf: Optionally add bibliographic entries to this list.
  • pipeline_todos - TODO string in main.nf: Only uncomment below if logic in toolCitationText/toolBibliographyText has been filled!
  • pipeline_todos - TODO string in methods_description_template.yml: #Update the HTML below to your preferred methods description, e.g. add publication citation for this pipeline

❔ Tests ignored:

✅ Tests passed:

Run details

  • nf-core/tools version 2.14.1
  • Run at 2024-07-11 17:39:54

@MatthiasZepper
Copy link
Member Author

Some progress:

  • Vlad Savelyev speedily fixed the "Multi Module Multi QC issue" for us, and the MultiQC release 1.22.2 was pushed just for us. Patching the MultiQC module to the latest version thus fixes MultiQC report is missing fastQC results on the dev branch #1303 in conjunction with my proposed changes in the publishDir directives. One issue is down, three to go.
  • After some testing, I finally understood that the YAML config in table_columns_visible expects the actual module names and not the original module name used by MultiQC. Thus, I could now successfully suppress the display of the unwanted column. Two issues is down, two to go.

@drpatelh
Copy link
Member

Thanks @MatthiasZepper !!

Two issues is down, two to go.

I read through your write-up but was a little unclear as to what is still missing here?

@pinin4fjords
Copy link
Member

To copy in @MatthiasZepper's note on this from Slack:

I am somewhat stuck with #1308, both because of a lack of time recently and also a lack of ideas. I believed that I fixed 3 of the 4 issues with the 4th, the inconsistent naming of the TrimGalore! output, being somewhat neglectable.

However, it turns out that I did not fix the main issue yet. The reports generated by MultiQC when run inside the pipeline and manually on the outdir of the pipeline differ. The manual runs look exactly how I want them, so I thought it should be good, but the pipeline version does not work alike.

In the pipeline version, the path_filters in the MultiQC config (workflows/rnaseq/assets/multiqc/multiqc_config.yml) are not applied:

module_order:
  - fastqc:
      name: "FastQC (raw)"
      anchor: "fastqc_raw"
      info: "This section of the report shows FastQC results before adapter trimming."
      path_filters:
        - "**/raw/*.zip"
  - cutadapt
  - fastp
  - fastqc:
      name: "FastQC (trimmed)"
      anchor: "fastqc_trimmed"
      info: "This section of the report shows FastQC results after adapter trimming."
      path_filters:
        - "**/trim/*.zip"

I think that is because the file paths in the ch_multiqc_files are still those to the work dir and to not correspond yet to the final folder structure specified by the publishDir directives when I mix the output into the channel…

ch_multiqc_files = ch_multiqc_files.mix(FASTQ_FASTQC_UMITOOLS_FASTP.out.fastqc_raw_zip.collect{it[1]})

… but since I can’t do a proper introspection into the channel (a .view() or .collectFile() completely crashes the pipeline), I don’t know for sure.

@pinin4fjords
Copy link
Member

OK, I know the fix @MatthiasZepper, I sorted this in riboseq. The issue is that the file structure is flat by the time it gets to MultiQC.

We need to do like:

    if (params.trimmer == 'trimgalore') {
        process {
            withName: '.*:FASTQ_FASTQC_UMITOOLS_TRIMGALORE:FASTQC' {
                ext.prefix = { "${meta.id}_raw" }
                ext.args   = '--quiet'
                publishDir = [
                    path: { "${params.outdir}/preprocessing/fastqc" },
                    mode: params.publish_dir_mode,
                    saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
                ]
            }
        }
    }

... and then:

module_order:
  - fastqc:
      name: "FastQC (raw)"
      info: "This section of the report shows FastQC results before adapter trimming."
      path_filters:
        - "*_raw_fastqc.zip"

So we're using the prefix sent to FASTQC to mark the outputs appropriately. I'll push a commit to your branch if I can, but this is the way to solve it.

@MatthiasZepper
Copy link
Member Author

MatthiasZepper commented Jun 20, 2024

OK, I know the fix @MatthiasZepper, I sorted this in riboseq. The issue is that the file structure is flat by the time it gets to MultiQC.

So we're using the prefix sent to FASTQC to mark the outputs appropriately. I'll push a commit to your branch if I can, but this is the way to solve it.

Thank you so much! That would be fantastic! You should be able to push to the branch since you are a maintainer, but just in case, I have also invited to as a collaborator to my fork!

@pinin4fjords
Copy link
Member

@MatthiasZepper OK, committed! Had a quick check and I think this works, though I note that the trimgalore subworkflow doesn't do a post-trim FASTQ, which we might want to address at some point....

Anyway, I'll let you take it home from here :-)

@MatthiasZepper
Copy link
Member Author

Thank you so much! I will try my best to finish this quickly now!

though I note that the trimgalore subworkflow doesn't do a post-trim FASTQ, which we might want to address at some point....

Oh, it does. It is just confusing, because TrimGalore! in itself is a wrapper script around cutadapt and FastQC. So FastQC is not run as a Nextflow process but by the TrimGalore Perl script.

@pinin4fjords
Copy link
Member

Ahh right, thought I was forgetting something ;-). So there is probably a missing bit to get those outputs prefixed correctly, but you know what to do.

@pinin4fjords
Copy link
Member

@MatthiasZepper in case it's impacting on your work, we've noticed that the lastest MultiQC has generated some issues in the workflow. We're looking into it.

@MatthiasZepper MatthiasZepper force-pushed the MultiQC_FastQC_bug branch 3 times, most recently from c005701 to 3ad2adf Compare July 2, 2024 16:55
@MatthiasZepper MatthiasZepper marked this pull request as ready for review July 3, 2024 13:06
@MatthiasZepper
Copy link
Member Author

I think/hope/wish I am done with this PR. It now fixes 3 out of the 4 issues that were spotted with the TrimGalore! renaming being left. However, I perceive this as a minor issue and think that it could be tackled some when later if needed.

@pinin4fjords
Copy link
Member

Great, thanks @MatthiasZepper ! Just to be clear, you don't need an updated MultiQC?

@MatthiasZepper
Copy link
Member Author

MatthiasZepper commented Jul 4, 2024

Great, thanks @MatthiasZepper ! Just to be clear, you don't need an updated MultiQC?

It did need changes to MultiQC, since the previous version was not working. However, the critical bug was fixed with 1.22.2 and my updates to the umi-tools module were already contained within 1.22.3.

Therefore, with this PR, we should now see (re)introduced:

  • MultiQC report has a FastQC (raw) and FastQC (trimmed) section again, closes MultiQC report is missing fastQC results on the dev branch #1303
  • MultiQC report now features an umi-tools extract statistics. While not very helpful for the basic extraction, it will be quite useful for the regex mode of umi-tools.
  • The FastQC duplicate estimate is hidden from the General Statistics table (since umi-tools / picard duplicate estimates are run on the aligned reads and thus more accurate)
  • MultiQC report now correctly picks up and displays the umi-tools dedup statistics. This should close or at least represent significant progress towards a solution of Improve/add UMI deduplication metrics #1277 .
  • Account for some MultiQC config changes. e.g. reverseColors is now reverse_colors in the custom content stuff. Since the custom content is, however, not displayed, it is hard to fully test this. It at least tackles all the warning messages about deprecated config that have been displayed before.
  • I have sneaked in instructions for processing the Watchmaker UMIs with the pipeline. Unrelated to the purpose of this PR, but since it was a tiny update it felt excessive to make a seperate PR for this.

@pinin4fjords
Copy link
Member

Hope you don't mind @MatthiasZepper - just illustrating in those last couple of commits what I meant. So use the module in its updated form, but also have a patch to help with updates.

I also removed something I added to the patch earlier and which shouldn't have been there, and bumped the module (think it was just Maxime mucking about with stubs)

@MatthiasZepper
Copy link
Member Author

Hope you don't mind @MatthiasZepper - just illustrating in those last couple of commits what I meant. So use the module in its updated form, but also have a patch to help with updates.

No, I don't mind at all. In contrast, I highly appreciate your help here! Please push your changes also to the draft PR of the modules' repo right away so they don't get lost in translation!.

Fixing the dupradar module was not even in the original scope of this PR. I think, the first changes got introduced by rebasing my draft PR to the dev branch, and then I packed some more changes in there because a colleague suggested them and felt that it was too minor for an PR on its own right ?!?

In either way, I would like to see the MultiQC fixes merged and am happy to take everything else out, if it complicates the review and decision.

@pinin4fjords pinin4fjords changed the title MultiQC report: Issues with FastQC Various MultiQC issues: FastQC sections for raw and trimmed reads // umi-tools dedup and extraction plots, custom content styling. Jul 11, 2024
Copy link
Member

@pinin4fjords pinin4fjords left a comment

Choose a reason for hiding this comment

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

For me this is good to go. I've given the MultiQC report a check, and it's looking good to me when I check for the recent issues.

Module state is per @MatthiasZepper's module PR, temporarily achieved via a patch pending the merge of that PR. We can merge as-is, or just merge that module PR (since everything seems to be working) and update here, removing the patch.

@pinin4fjords
Copy link
Member

@MatthiasZepper I think the failure here is because the nf-test didn't run on the module PR (maybe touching the template file isn't enough), and we need to update the tests to reflect the changes. I'll take a look.

@pinin4fjords
Copy link
Member

nf-core/modules#5966

@MatthiasZepper
Copy link
Member Author

@MatthiasZepper I think the failure here is because the nf-test didn't run on the module PR (maybe touching the template file isn't enough), and we need to update the tests to reflect the changes. I'll take a look.

Thanks. But don't overthink it, since I probably just screwed up undoing the local changes.

nf-core modules patch -r dupradar did not work (it complained about the presence of a nextflow.config in the module's directory, so is evidently not yet adapted for the new pipeline structure with separate module configs) and thus I ended up removing the .diff file with git rm, which of course left the dangling reference in the modules.json that I was not aware of. So the failing test was presumably just a layer 8 issue.

@pinin4fjords
Copy link
Member

Thanks @MatthiasZepper! Module update done, lights are green. Merge away when you're ready.

@MatthiasZepper
Copy link
Member Author

MatthiasZepper commented Jul 11, 2024

For me this is good to go. I've given the MultiQC report a check, and it's looking good to me when I check for the recent issues.

I did not have time to test the latest iteration of this PR until just now, but to me it seems the MultiQC issues are not fixed (or new ones emerged - can't tell if I overlooked something before, because I have deleted the results from the previous test runs already).

1.) The FastQC section is missing samples. Only 2 samples in the FastQC, but 5 samples in the umi-tools module, if I use the test profile:

fastqc_sequence_counts_plot
umitools_extract_regex_barplot

Also, the sample names are oddly mixed up. I never paid much attention to the contents of the test data, but it seems that some tools only process parts of the data or perform some weird renaming of the samples?

2.) The Dupradar plot is there, but no lines are shown and the sample values are all 0,0. That might be due to the small testdata being poorly suited to test the tool, but of course it could also be due to an invalid config or incorrect data processing.

dupradar-plot

Can you as a first step, please let me know if it is the same with you or not?

@pinin4fjords
Copy link
Member

Oh goddamn, you're right on FastQC, I'll have a dig. Dupradar doesn't look like that for me though:

Screenshot 2024-07-11 at 17 14 56

@pinin4fjords
Copy link
Member

Only 2 samples in the FastQC

This is actually because there are only two e.g. _raw_fastqc.zip files getting to the multiqc process, so probably a workflow issue. I'll figure it out

@pinin4fjords
Copy link
Member

@MatthiasZepper think I fixed the FASTQC thing at least (see last commit) - could you check again?

@pinin4fjords
Copy link
Member

Also, could you give me the UMI params you're testing with, and which are not set in the test profile by default?

@MatthiasZepper
Copy link
Member Author

MatthiasZepper commented Jul 12, 2024

could you check again?

Pipeline run is queued and about to start as we speak (as I type).

Also, could you give me the UMI params you're testing with, and which are not set in the test profile by default?

Of course. Mind, however, that this is a completely nonesense pattern. I am defining three fixed bases at the start, but allowing for two random substitutions. I just wanted to make the UMI-tools extract plot a little more informative (and take that module to a true test), because with a fixed pattern there are no failures when extracting.

with_umi: true
umitools_extract_method: "regex"
umitools_bc_pattern: "^(?P<umi_1>CGA.{8}){s<=2}.*"
umi_dedup_stats: true

Dupradar doesn't look like that for me though

Then this is probably a side effect of my random UMI specification that I did not think through properly or an issue with my browser.

@pinin4fjords
Copy link
Member

pinin4fjords commented Jul 12, 2024

I've also looked into the UMI thing. I don't think it can ever have worked (unless there is some regression I was unaware of).

Multi QC is parsing log lines like:

output generated by extract -I SRR6357076_1.fastq.gz --read2-in=SRR6357076_2.fastq.gz -S RAP1_IAA_30M_REP1.umi_extract_1.fastq.gz --read2-out=RAP1_IAA_30M_REP1.umi_extract_2.fastq.gz --extract-method=string --bc-pattern=NNNN

Those input files are taken directly from the sample sheet. Other processes where FASTQ files have been merged end up using a prefix on their output, so the log for umitools extract looks like:

# output generated by extract -I WT_REP1_1.merged.fastq.gz --read2-in=WT_REP1_2.merged.fastq.gz -S WT_REP1.umi_extract_1.fastq.gz --read2-out=WT_REP1.umi_extract_2.fastq.gz --extract-method=regex --bc-pattern=^(?P<umi_1>CGA.{8}){s<=2}.*

To fix this, someone will probably have to alter umitools/extract to allow symlinking of input files to use the prefix. Suggest you create an issue, but probably not something to address here.

@pinin4fjords
Copy link
Member

Dupradar doesn't look like that for me though

Then this is probably a side effect of my random UMI specification that I did not think through properly or an issue with my browser.

OK, I see it now with your parameters, so it's not your browser! Not sure of the fix though as it relates to your params (I haven't dug much into the UMI stuff), and don't think it's MultiQC related. So probably one for a separate issue as well.

@MatthiasZepper
Copy link
Member Author

I've also looked into the UMI thing. I don't think it can ever have worked (unless there is some regression I was unaware of).

I fear, I can't follow you without being a tad more specific than thing. 🙃

I think, you are aware of that there are two umi-tools steps in the pipeline:

  1. umi-tools extract: This indeed has never worked, because there was no module for that tool. I wrote it recently and it was included in MultiQC 1.22.3. Hence, a summary of the extraction success is now newly included in rnaseq 3.15.dev, since we are using 1.23 now.
  2. umi-tools dedup: There has been a module for this subtool, but the file search pattern was incorrect for a while. I fixed that as well to address Improve/add UMI deduplication metrics #1277.

The examples you show evidently refer to extract, but I fail to see the difference. Both take some SRR sample names as input and have some proper output file names? If the pipeline supports automatically merging multipart input FastQs into single samples, maybe we need to generate some additional MultiQC config to rename the samples there as well?

@pinin4fjords
Copy link
Member

Yes, I meant your earlier flagged inconsistency in the names on the extract plots.

Being more specific, the sample IDs are derived like this, which means they're derived from data lines like:

# stdin                                   : <_io.TextIOWrapper name='SRR6357073_1.fastq.gz' encoding='ascii'>

... i.e. from the actual, bare, FASTQ file names, exactly as supplied to the pipeline. The FASTQs that . I might suggest that the simplest thing would be to work off the stdout line instead:

# stdout                                  : <_io.TextIOWrapper name='RAP1_UNINDUCED_REP1.umi_extract.fastq.gz' encoding='ascii'>

... but obviously we'd then we waiting on a release. MultiQC renaming looks good, and I just had a quick stab, but I can't see how to do it quickly (the MultiQC module really needs a file input for the renaming TSV).

To my mind we should probably get this merged (assuming you confirm the FASTQC fix works), and deal with this down the line.

@MatthiasZepper MatthiasZepper merged commit 18d8d10 into nf-core:dev Jul 12, 2024
34 checks passed
@MatthiasZepper MatthiasZepper deleted the MultiQC_FastQC_bug branch July 12, 2024 13:20
@pinin4fjords pinin4fjords linked an issue Jul 19, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom content plots missing in MultiQC ouptut MultiQC report is missing fastQC results on the dev branch
3 participants