Replace-names

In my MultiQC reports, the sample names have several different patterns due to different analyses. The patterns include barcodeXX, barcodeXX.reor_consensus, and barcodeXX.reor_consensus.fasta. I would like to use --replace-names to get rid of the suffixes, so I added the following code to my config file:

sample_names_replace_regex: true

sample_names_replace:

  "barcode(\\d{2})\\.reor_consensus(\\.fasta)?": "barcode\\1"

However, it did not remove the suffixes as expected. I need help, Thanks

If it’s just suffixes, you don’t want to replace the names - you want to clean them.

In your case, your config should look something like this:

extra_fn_clean_exts:
  - ".reor_consensus"

That’ll match .reor_consensus anywhere in a sample name and remove it - and anything after it (including the .fasta).

Hope that helps!

Phil

Dear ewels

Thank you for the reply, but it didn’t work for me.

I have tried

extra_fn_clean_exts:

  - ".reor_consensus"

and/or

extra_fn_clean_trim:

  - ".reor_consensus"

including the --replace-names, but nothing works.

From multiqc --verbose

it does register the pattern specified in the config, but somehow it doesn’t do the job as expected.

[2026-01-12 00:29:10] multiqc.config                                     [DEBUG  ]  Added to filename clean extensions: [['.reor_consensus']]
[2026-01-12 00:29:10] multiqc.config                                     [DEBUG  ]  Added to filename clean trimmings: [['.reor_consensus']]

here is one example, the CheckM2 report didn’t clean the file name: the name ends with .reor_consensus, but even with the extra_fn_clean_exts: in the config, it still doesn’t cleanup the suffix.

[2026-01-12 00:29:34] multiqc.core.exec_modules                          [DEBUG  ]  Running module: checkm2
[2026-01-12 00:29:34] multiqc.modules.checkm2.checkm2                    [INFO   ]  Found 16 reports
[2026-01-12 00:29:34] multiqc.report                                     [DEBUG  ]  Wrote data file multiqc_checkm2.txt
[2026-01-12 00:29:34] multiqc.report                                     [DEBUG  ]  Wrote data file multiqc_checkm2.json
[2026-01-12 00:29:34] multiqc.plots.table_object                         [DEBUG  ]  Table key 'Additional_Notes' not found in data for 'checkm2-first-table'. Skipping. Check for possible typos between data keys and header keys
[2026-01-12 00:29:34] multiqc.plots.plot                                 [DEBUG  ]  merge_with_previous for checkm2-first-table: found old_data = False
[2026-01-12 00:29:34] multiqc.plots.plot                                 [DEBUG  ]  merge_with_previous for checkm2-first-table: no old data or empty, using new data only
[2026-01-12 00:29:34] multiqc.core.software_versions                     [DEBUG  ]  Reading software versions from config.software_versions
[2026-01-12 00:29:34] multiqc.core.software_versions                     [DEBUG  ]  Reading software versions settings from: pipeline_info/bacteria_mqc_versions.yaml

By the way, the multiqc version is V1.33

Ah, you’re not doing anything wrong. It looks like these modules are incorrectly not using the self.clean_s_name() function from MultiQC which does this sample name cleaning.

I’ve just opened a PR to address this:

Once that is merged and released, it should work. You can try installing from this dev branch to test locally in the mean time:

pip install git+https://github.com/MultiQC/MultiQC.git@musing-beaver

Thanks for checking, hopefully this should do the job. Let me know how you get on!

Thank you ewels, One more thing, would this fix also apply to custom contents?

Custom content should already be correctly applying the sample name cleaning, so that should already work :+1:

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