# Can use BWA-MEM to concatenated files

**URL:** <https://help.galaxyproject.org/t/can-use-bwa-mem-to-concatenated-files/10097>\
**Category:** Uncategorized\
**Tags:** troubleshooting, mapping, picard\_markduplicates\
**Created:** [May 20, 2023, 5:40pm UTC](https://help.galaxyproject.org/t/can-use-bwa-mem-to-concatenated-files/10097 "2023-05-20T17:40:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sofi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Sofi](https://help.galaxyproject.org/u/Sofi)\
**Post date:** [May 20, 2023, 5:40pm UTC](https://help.galaxyproject.org/t/can-use-bwa-mem-to-concatenated-files/10097/1 "2023-05-20T17:40:39Z")

</div>

Hi everyone! I continue to learn work in galaxy.  
I have 4files R1 and 4files R2 from 1 patient.  
I need to join all R1-files and all R2-files in 2 different files so I used **concatenate multiple datasets** tool. After this I was trying to use tool **map with bwa-mem** but it gives me an error. (I also trying use outher tools of concatenate but it doesn’t work)  
Also I want to use **Set read groups information** (by Picard) for duplicates sorting (I think I need LB). But I really dont understand what to write in empty fields for ID and LB.  
I read help in bwa-mem2 but still have this error…  
My history [https://usegalaxy.org/u/sofi\_23/h/panel-12392](https://usegalaxy.org/u/sofi_23/h/panel-12392)

What I do wrong? Can I sort duplicates in bwa-mem or I need tool **Markduplicates**?  
I’d appreciate any help

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [May 21, 2023, 9:22pm UTC](https://help.galaxyproject.org/t/can-use-bwa-mem-to-concatenated-files/10097/2 "2023-05-21T21:22:52Z")

</div>

Hi @Sofi

Clicking into the logs reports more details about the error. How to find job logs: [Troubleshooting errors](https://training.galaxyproject.org/training-material/faqs/galaxy/analysis_troubleshooting.html)

> Tool Standard Error   
> [M::mem\_pestat] **skip orientation FF as there are not enough pairs**  
> [M::mem\_pestat] analyzing insert size distribution for orientation FR…  
> [M::mem\_pestat] (25, 50, 75) percentile: (1178, 3439, 6248)  
> [M::mem\_pestat] low and high boundaries for computing mean and std.dev: (1, 16388)  
> [M::mem\_pestat] mean and std.dev: (3927.75, 2950.43)  
> [M::mem\_pestat] low and high boundaries for proper pairs: (1, 21458)  
> [M::mem\_pestat] analyzing insert size distribution for orientation RF…  
> [M::mem\_pestat] (25, 50, 75) percentile: (1329, 3521, 6080)  
> [M::mem\_pestat] low and high boundaries for computing mean and std.dev: (1, 15582)  
> [M::mem\_pestat] mean and std.dev: (3874.29, 2817.50)  
> [M::mem\_pestat] low and high boundaries for proper pairs: (1, 20333)  
> [M::mem\_pestat] **skip orientation RR as there are not enough pairs**  
> [mem\_sam\_pe] **paired reads have different names** : “NB501410:184:HJY53BGXB:3:11401:17202:1034”, “NB501410:184:HJY53BGXB:2:11101:5667:1046”

The tool is reporting in a few places that it isn’t finding “enough” pairs of R1 and R2 reads. I’m guessing the individual fastq files were not stacked together in the same order.

Suggested ways to troubleshoot:

1. **Concatenate** the reads again, and make sure that the ordering is the same between the R1 and R2 files.
2. Then try running **Fastq Info** on both datasets together. This is a top level format check.
3. Once that passes, run some QA on the reads to access the scientific content. At least run **FastQC** , it doesn’t change the data.
4. Proceed with trimming if wanted. If you do that, run **FastQC** again _after_ to review what changed.
5. After everyone above is done, try mapping again.

* * *

These tutorials can help with understanding fastq data (format/content/variants) along with example QA steps/tools.

- [NGS data logistics](https://training.galaxyproject.org/training-material/topics/introduction/tutorials/galaxy-intro-ngs-data-managment/tutorial.html)
- [Quality Control](https://training.galaxyproject.org/training-material/topics/sequence-analysis/tutorials/quality-control/tutorial.html)
- [Mapping](https://training.galaxyproject.org/training-material/topics/sequence-analysis/tutorials/mapping/tutorial.html)

Also see domain/topic tutorials for protocol-specific QA steps. That entire training site can be searched with keywords like tool names or datatypes, and most tutorials have a workflow. Using tutorial data along with a workflow is a quick way to create a “reference history” to compare to when running your own data through similar tools.

- **Concatenate** tool is listed here with usage examples: [Data Manipulation Olympics](https://training.galaxyproject.org/training-material/topics/introduction/tutorials/data-manipulation-olympics/tutorial.html)
- [Search Tutorials](https://training.galaxyproject.org/training-material/search?query=bwa-mem) (query=bwa-mem)
- or start at the home page and navigate by domain

* * *

_Notes:_

If the reads are all from the _same sample_ but sequenced across multiple lanes, what you are doing now is probably the correct way to process the reads.

If the reads are all from _different samples_ (could be the same “patient”), analyzing those samples distinctly at this stage in the processing is usually important. You can use a paired-end list collection instead (R1 + R2 in the same collection), or two list collections (R1 in one, R2 in another), and run those through in batch. See [Using dataset collections](https://training.galaxyproject.org/training-material/topics/galaxy-interface/tutorials/collections/tutorial.html) and search the site with “collection” to find more. There are special ways to organize and tag data that are likely a good choice for you.

* * *

* * *

> [@Sofi](#):
>
> Also I want to use **Set read groups information** (by Picard) for duplicates sorting (I think I need LB). But I really dont understand what to write in empty fields for ID and LB.  
> …  
> What I do wrong? Can I sort duplicates in bwa-mem or I need tool **Markduplicates**?

The [Variant Analysis](https://training.galaxyproject.org/training-material/topics/variant-analysis/) tutorials have answers for these.

And … maybe consider joining the training that is happening this week. All of the tutorials above are supported, with live help from the authors and instructors. Once you learn the best-practice methods, it will be much easier to understand how to use tools, and it what order, with your own data (potentially with adapted workflows – so so much faster! and reusable). [Smörgåsbord 3: A week of Free, Online, Galaxy Training supported by the Global Galaxy Training Community](https://help.galaxyproject.org/t/smorgasbord-3-a-week-of-free-online-galaxy-training-supported-by-the-global-galaxy-training-community/9786)

Hope that helps!

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [December 20, 2023, 8:13pm UTC](https://help.galaxyproject.org/t/can-use-bwa-mem-to-concatenated-files/10097/3 "2023-12-20T20:13:27Z")

</div>


