Re: [R] renameSeqlevels

2017-02-14 Thread Martin Morgan
Rsamtools and GenomicAlignments are Bioconductor packages so ask on the 
Bioconductor support site


  https://support.bioconductor.org

You cannot rename the seqlevels in the bam file; you could rename the 
seqlevels in the object(s) you have created from the bam file.


Martin

On 02/14/2017 09:17 AM, Teresa Tavella wrote:

Dear all,

I would like to ask if it is possible to change the seqnames of a bam file
giving a vector of character to the function renameSeqlevels. This is
because in order to use the fuction summarizeOverlap or count/find, the
seqnames have to match.

From the bamfile below I have extracted the locus annotations form the

seqnames (i.e ERCC2, NC_001133.9...etc) and I have created a list (same
length as the seqlevels of the bam file).


*bamfile*
GAlignments object with 6 alignments and 0 metadata columns:

seqnames


  [1]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [2]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [3]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [4]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [5]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [6]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  strand   cigarqwidth start   end width njunc
 
  [1]  + 8M2D27M35  1025  106137 0
  [2]  + 8M2D27M35  1025  106137 0
  [3]  - 36M36  1025  106036 0
  [4]  - 36M36  1026  106136 0
  [5]  + 35M35  1027  106135 0
  [6]  + 35M35  1027  106135 0
  ---
*gffile*
GRanges object with 6 ranges and 12 metadata columns:
 seqnames   ranges strand |   source type score
   |   
  [1] NC_001133.9 [ 24837,  25070]  + | s_cerevisiae exon  
  [2] NC_001133.9 [ 25048,  25394]  + | s_cerevisiae exon  
  [3] NC_001133.9 [ 27155,  27786]  + | s_cerevisiae exon  
  [4] NC_001133.9 [ 73431,  73792]  + | s_cerevisiae exon  
  [5] NC_001133.9 [165314, 165561]  + | s_cerevisiae exon  
  [6] NC_001133.9 [165388, 165781]  + | s_cerevisiae exon  
  phase gene_id  transcript_id exon_number   gene_name
 
  [1]   XLOC_40 TCONS_0191   1FLO9
  [2]   XLOC_40 TCONS_0192   1FLO9
  [3]   XLOC_41 TCONS_0193   1FLO9
  [4]   XLOC_55 TCONS_0200   1   YAL037C-A
  [5]   XLOC_75 TCONS_0100   1 YAR010C
  [6]   XLOC_75 TCONS_0219   1 YAR010C
 oId nearest_ref  class_code
   
  [1]   {TRINITY_GG_normal}16_c1_g1_i1.mrna1rna8   x
  [2]   {TRINITY_GG_normal}16_c0_g1_i1.mrna1rna8   x
  [3]   {TRINITY_GG_normal}12_c0_g1_i1.mrna1rna8   x
  [4]{TRINITY_GG_normal}3_c3_g1_i1.mrna1   rna31   x
  [5] {TRINITY_GG_normal}3479_c0_g1_i1.mrna1   rna77   x
  [6]   {TRINITY_GG_normal}24_c0_g1_i1.mrna1   rna77   x
   tss_id
  
  [1]   TSS42
  [2]   TSS43
  [3]   TSS44
  [4]   TSS71
  [5]  TSS118
  [6]  TSS118
  ---

It is possible to replace the seqlevels names with the list?
I have tried:

bamfile1 <- renameSeqlevels(seqlevels(bamfile), listx)

Thank you for any advice,

Kind regards,

Teresa



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




This email message may contain legally privileged and/or...{{dropped:2}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] renameSeqlevels

2017-02-14 Thread Teresa Tavella
Dear all,

I would like to ask if it is possible to change the seqnames of a bam file
giving a vector of character to the function renameSeqlevels. This is
because in order to use the fuction summarizeOverlap or count/find, the
seqnames have to match.
>From the bamfile below I have extracted the locus annotations form the
seqnames (i.e ERCC2, NC_001133.9...etc) and I have created a list (same
length as the seqlevels of the bam file).


*bamfile*
GAlignments object with 6 alignments and 0 metadata columns:

seqnames


  [1]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [2]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [3]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [4]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [5]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  [6]
DQ459430_gene=ERCC2_loc:ERCC2|1-1061|+_exons:1-1061_segs:1-1061
  strand   cigarqwidth start   end width njunc
 
  [1]  + 8M2D27M35  1025  106137 0
  [2]  + 8M2D27M35  1025  106137 0
  [3]  - 36M36  1025  106036 0
  [4]  - 36M36  1026  106136 0
  [5]  + 35M35  1027  106135 0
  [6]  + 35M35  1027  106135 0
  ---
*gffile*
GRanges object with 6 ranges and 12 metadata columns:
 seqnames   ranges strand |   source type score
   |   
  [1] NC_001133.9 [ 24837,  25070]  + | s_cerevisiae exon  
  [2] NC_001133.9 [ 25048,  25394]  + | s_cerevisiae exon  
  [3] NC_001133.9 [ 27155,  27786]  + | s_cerevisiae exon  
  [4] NC_001133.9 [ 73431,  73792]  + | s_cerevisiae exon  
  [5] NC_001133.9 [165314, 165561]  + | s_cerevisiae exon  
  [6] NC_001133.9 [165388, 165781]  + | s_cerevisiae exon  
  phase gene_id  transcript_id exon_number   gene_name
 
  [1]   XLOC_40 TCONS_0191   1FLO9
  [2]   XLOC_40 TCONS_0192   1FLO9
  [3]   XLOC_41 TCONS_0193   1FLO9
  [4]   XLOC_55 TCONS_0200   1   YAL037C-A
  [5]   XLOC_75 TCONS_0100   1 YAR010C
  [6]   XLOC_75 TCONS_0219   1 YAR010C
 oId nearest_ref  class_code
   
  [1]   {TRINITY_GG_normal}16_c1_g1_i1.mrna1rna8   x
  [2]   {TRINITY_GG_normal}16_c0_g1_i1.mrna1rna8   x
  [3]   {TRINITY_GG_normal}12_c0_g1_i1.mrna1rna8   x
  [4]{TRINITY_GG_normal}3_c3_g1_i1.mrna1   rna31   x
  [5] {TRINITY_GG_normal}3479_c0_g1_i1.mrna1   rna77   x
  [6]   {TRINITY_GG_normal}24_c0_g1_i1.mrna1   rna77   x
   tss_id
  
  [1]   TSS42
  [2]   TSS43
  [3]   TSS44
  [4]   TSS71
  [5]  TSS118
  [6]  TSS118
  ---

It is possible to replace the seqlevels names with the list?
I have tried:

bamfile1 <- renameSeqlevels(seqlevels(bamfile), listx)

Thank you for any advice,

Kind regards,

Teresa
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.