# Plot a histogram of different samples as a bargraph with custom content

**URL:** <https://community.seqera.io/t/plot-a-histogram-of-different-samples-as-a-bargraph-with-custom-content/1648>\
**Category:** Ask for help\
**Tags:** multiqc\
**Created:** [January 23, 2025, 1:21pm UTC](https://community.seqera.io/t/plot-a-histogram-of-different-samples-as-a-bargraph-with-custom-content/1648 "2025-01-23T13:21:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/julia/32/1381_2.png) [@Julia](https://community.seqera.io/u/Julia)\
**Post date:** [January 23, 2025, 1:21pm UTC](https://community.seqera.io/t/plot-a-histogram-of-different-samples-as-a-bargraph-with-custom-content/1648/1 "2025-01-23T13:21:38Z")

</div>

Hi,  
I have a nextflow pipeline that produces a TSV file with a histogram of m/z values for each input sample (with columns `bin` and `value`, the bins are the same for all samples):

```auto
266.6666666666667 - 276.5	0.0
276.5 - 286.33333333333337	0.0
286.33333333333337 - 296.1666666666667	0.00036845983787767205
296.1666666666667 - 306.0	0.00036845983787767205
...

```

I would like to plot the histogram using custom content, i.e. in `multiqc_config.yaml`:

```auto
custom_data:
  mz_plot:
      plot_type: "bargraph"
      file_format: "tsv"
      section_name: "Histogram of the m/z values"
      pconfig:
        id: "histogram_mz"
        title: "Histogram of the m/z values"
        xlab: "Frequency"
        ylab: "m/z"

```

However, this will not create a histogram but will create a bar for each sample with the bins as the different categories, as shown here:

 ![histogram_mz](https://europe1.discourse-cdn.com/flex013/uploads/seqera/original/2X/3/36a30c4b6526001f25a5d4f6e8df84f4cc4ade13.png)

I have already encountered a similar situation where I had to write a custom module to swap out the sample id with the categorical variable but is there a way to achieve this without having to do that?  
Can i somehow put the bins onto the y-axis and use the samples as categories in the bargraphs just using custom content?

Best, Julia

---

<div class="post-metadata">

**Author:** ![vlad.savelyev](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/vlad.savelyev/32/576_2.png) [@vlad.savelyev](https://community.seqera.io/u/vlad.savelyev)\
**Post date:** [January 23, 2025, 2:06pm UTC](https://community.seqera.io/t/plot-a-histogram-of-different-samples-as-a-bargraph-with-custom-content/1648/2 "2025-01-23T14:06:41Z")

</div>

Hi Julia!

This is the expected multi-sample bargraph format:

> <https://github.com/MultiQC/test-data/blob/5f670496d2a209189b926b36934e0438d4a16d9f/data/custom_content/no_config/bargraph_multiple_samples_mqc.csv>

The first column should contain sample names, and the header line should have category names.

---

<div class="post-metadata">

**Author:** ![Julia](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/julia/32/1381_2.png) [@Julia](https://community.seqera.io/u/Julia)\
**Post date:** [January 23, 2025, 3:33pm UTC](https://community.seqera.io/t/plot-a-histogram-of-different-samples-as-a-bargraph-with-custom-content/1648/3 "2025-01-23T15:33:21Z")

</div>

Thank you, that is exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/system/32/2402_2.png) [@system](https://community.seqera.io/u/system)\
**Post date:** [January 30, 2025, 3:34pm UTC](https://community.seqera.io/t/plot-a-histogram-of-different-samples-as-a-bargraph-with-custom-content/1648/4 "2025-01-30T15:34:20Z")

</div>

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