Answers.Body: <p>What tool did you use to replace the read names? Can you modify that to split up the reads into separate files or encode the cell barcode in the read description instead of the read name? </p>
  
  <p>Typically is it assumed by many tools that the FASTQ read names are unique. you could have issues with BWA and split alignments but I don't know if that pertains to your data.  I think the best you can do is the sanity check the results at each step of the process.</p>
  
  <p>In the fastq format (<a href="https://en.wikipedia.org/wiki/FASTQ_format" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/FASTQ_format</a>) on the first line denoted by the '@' there can be two values separated by a space.  The first is the name and the second is the description.  </p>
  
  <p>So an example would be:</p>
  
  <pre><code>@Original_read_name CGAGGCTG_TATCCTCT_AGTCCA
  ATCGATCATGATGACA
  +
  @&amp;%*@(%@%*($!##!
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-18T13:02:14.140Z
Answers.Text: The classic way to do this would be to append the barcodes to the read name such that the read name looks like: `@Original_read_name_CGAGGCTG_TATCCTCT_AGTCCA`, If the barcodes are extacted from the read sequences themselves, this processing can be achevied using `umi_tools extract`
Answers.UserDisplayName: Ian Sudbery
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-17T19:51:44.183Z
Answers.Text: In this iteration I did it using awk, do you mean incorporating it in the first line after the sequence identifier? I can certainly modify the script.
Answers.UserDisplayName: gc5
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-17T20:02:45.900Z
Answers.Text: I mean the one defined as `entry.comment` [here](https://pysam.readthedocs.io/en/latest/api.html#pysam.FastxFile)?
Answers.UserDisplayName: gc5
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-17T20:37:37.703Z
Answers.Text: I edited my answer to address your question
Answers.UserDisplayName: Bioathlete
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-17T21:42:49.863Z
Answers.Text: I noticed now that BWA does not preserve read description, I should probably append cell barcode to read name or this may introduce problems?
Answers.UserDisplayName: gc5
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-17T19:35:25.600Z
Answers.LastActivityDate: 2018-10-17T20:39:48.517Z
Answers.LastEditDate: 2018-10-17T20:39:48.517Z
Answers.UserDisplayName: Bioathlete
Body: <p>I am preprocessing a set of scTHSSeq reads in which each read sequence identifier has been replaced with the cell barcode, e.g.:</p>
  
  <pre><code>@CGAGGCTG_TATCCTCT_AGTCCA
  ...
  ...
  ...
  @CGAGGCTG_TATCCTCT_GGTACG
  ...
  </code></pre>
  
  <p>The read sequence identifier has been replaced with the cell barcode to be able to demultiplex alignments after bwa into a different bamfile for each cell.</p>
  
  <p>I ran the alignment using <a href="http://bio-bwa.sourceforge.net/bwa.shtml" rel="nofollow noreferrer">bwa mem</a> and I received no errors. However I would like to know if there are caveats or reasons why this approach may lead to misleading results.</p>
  
  <p>I will then proceed to remove PCR duplicates with <code>samtools rmdup</code> executed in each cell's bamfile and then I'd run peak calling using <a href="https://github.com/hms-dbmi/spp" rel="nofollow noreferrer">spp</a>.</p>
  
Tags: <read-mapping><reads><identifiers>
Title: Does read sequence identifier need to be unique for proper alignment?
ThreadText: # Does read sequence identifier need to be unique for proper alignment?
  
  (Asked by: username_0 on 2018-10-17)
  
  I am preprocessing a set of scTHSSeq reads in which each read sequence identifier has been replaced with the cell barcode, e.g.:
  
  ```
  @CGAGGCTG_TATCCTCT_AGTCCA
  ...
  ...
  ...
  @CGAGGCTG_TATCCTCT_GGTACG
  ...
  
  ```
  
  The read sequence identifier has been replaced with the cell barcode to be able to demultiplex alignments after bwa into a different bamfile for each cell.
  
  I ran the alignment using [bwa mem](http://bio-bwa.sourceforge.net/bwa.shtml) and I received no errors. However I would like to know if there are caveats or reasons why this approach may lead to misleading results.
  
  I will then proceed to remove PCR duplicates with `samtools rmdup` executed in each cell's bamfile and then I'd run peak calling using [spp](https://github.com/hms-dbmi/spp).
  
  **Tags:** read-mapping, reads, identifiers
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-17. Score: 2 | Accepted answer
  
  What tool did you use to replace the read names? Can you modify that to split up the reads into separate files or encode the cell barcode in the read description instead of the read name?
  
  Typically is it assumed by many tools that the FASTQ read names are unique. you could have issues with BWA and split alignments but I don't know if that pertains to your data. I think the best you can do is the sanity check the results at each step of the process.
  
  In the fastq format (<https://en.wikipedia.org/wiki/FASTQ_format>) on the first line denoted by the '@' there can be two values separated by a space. The first is the name and the second is the description.
  
  So an example would be:
  
  ```
  @Original_read_name CGAGGCTG_TATCCTCT_AGTCCA
  ATCGATCATGATGACA
  +
  @&%*@(%@%*($!##!
  
  ```
  
  > **Comments:**
  > **username_0**: In this iteration I did it using awk, do you mean incorporating it in the first line after the sequence identifier? I can certainly modify the script.  
  > **username_0**: I mean the one defined as `entry.comment` [here](https://pysam.readthedocs.io/en/latest/api.html#pysam.FastxFile)?  
  > **username_1**: I edited my answer to address your question  
  > **username_0**: I noticed now that BWA does not preserve read description, I should probably append cell barcode to read name or this may introduce problems?  
  > **username_2**: The classic way to do this would be to append the barcodes to the read name such that the read name looks like: `@Original_read_name_CGAGGCTG_TATCCTCT_AGTCCA`, If the barcodes are extacted from the read sequences themselves, this processing can be achevied using `umi_tools extract`  
  
  ---
  
  