[Bioc-sig-seq] PairwiseAlignedXStringSet to PairwiseAlignedFixedSubject

Stefan Bentink bentink at jimmy.harvard.edu
Wed Aug 4 18:31:08 CEST 2010


... exactly what I need, thanks!

Patrick Aboyoun wrote:
> Stefan,
> In this situation, rather than creating a new class, e.g. 
> BStringSetList, I would rather encourage use of the pattern() and 
> subject() extraction function, which return (Quality)AlignedXStringSet 
> objects, that can then in turn be passed to the aligned method. You 
> will get the values you are looking for, but without the need for 
> additional classes. Here is an example:
>
> > library(Biostrings)
> > aln <- pairwiseAlignment(c("able", "baker"), c("charlie", "dog"))
> > aln[1]
> Global PairwiseAlignedXStringSet (1 of 1)
> pattern: [1] abl-e
> subject: [3] arlie
> score: -14.36196
> > aln[2]
> Global PairwiseAlignedXStringSet (1 of 1)
> pattern: [1] bak
> subject: [1] dog
> score: -36.92151
> > aligned(pattern(aln))
>   A BStringSet instance of length 2
>     width seq
> [1]     5 abl-e
> [2]     3 bak
> > aligned(subject(aln))
>   A BStringSet instance of length 2
>     width seq
> [1]     5 arlie
> [2]     3 dog
>
>
> Patrick
>
>
> On 8/4/10 9:02 AM, Stefan Bentink wrote:
>> Patrick and Kasper,
>> Thanks for your immediate response. I see the problem. However, 
>> aligned(pwAligned) would be enough
>> at least for my application. And it should be possible to implement 
>> (returning a BStringSetList?) .
>> Thanks,
>> Stefan
>>
>>
>>
>> Patrick Aboyoun wrote:
>>> Stefan,
>>> While it would be possible to convert a PairwiseAlignedFixedSubject 
>>> (all patterns aligned to one subject) object to 
>>> PairwiseAlignedXStringSet (patterns and subjects are paired during 
>>> alignments) object, going the direction you are looking for would 
>>> not be possible. As Kasper mentioned, what can be done instead is 
>>> adding more methods for PairwiseAlignedXStringSet objects. If you 
>>> list them out, I'll see what can be done since not all operations, 
>>> e.g. consensusMatrix, that are applicable to the former class make 
>>> much sense with the later one.
>>>
>>>
>>> Cheers,
>>> Patrick
>>>
>>>
>>>
>>> On 8/4/10 8:12 AM, Kasper Daniel Hansen wrote:
>>>> Most likely these functions just needs to be implemented for both
>>>> classes, at least that is what I suspect Patrick will answer.
>>>>
>>>> So far you have listed
>>>>    as.character
>>>>    bi-directional conversion between the two classes (whihc may or may
>>>> not make sense)
>>>>
>>>> You seem to be alluding to other methods not being implemented.  If
>>>> that is the case, you should just list all of them, that will make it
>>>> much easier to fix.
>>>>
>>>> Kasper
>>>>
>>>> On Wed, Aug 4, 2010 at 11:04 AM, Stefan Bentink
>>>> <bentink at jimmy.harvard.edu>  wrote:
>>>>> Dear List Members,
>>>>> I'm using the function pairwiseAlignment from the Biostrings package.
>>>>> Depending on the
>>>>> input, the function returns either a PairwiseAlignedFixedSubject 
>>>>> (if you
>>>>> align a single pattern
>>>>> with a single subject) or a PairwiseAlignedXStringSet (if you 
>>>>> align multiple
>>>>> patterns with one
>>>>> or more subjects). There are some accessors which work on
>>>>> PairwiseAlignedFixedSubject
>>>>> objects but not on PairwiseAlignedXStringSet objects. To use those 
>>>>> accessors
>>>>> on a single
>>>>> element from a PairwiseAlignedXStringSet, one would have to make it a
>>>>> PairwiseAlignedFixedSubject.
>>>>> Is there any way to do that? Subsetting doesn't work since it 
>>>>> still returns
>>>>> a PairwiseAlignedXStringSet.
>>>>> Thanks,
>>>>> Stefan
>>>>>
>>>>>
>>>>> Code example:
>>>>> library(Biostrings)
>>>>> pattern1<- c("ACGT")
>>>>> pattern2<- c("CAGT")
>>>>> subject1<- c("CAACGTGGAT")
>>>>> subject2<- c("GAACAGTAAT")
>>>>>
>>>>> mat<- nucleotideSubstitutionMatrix(match = 1, mismatch = 0, 
>>>>> baseOnly =
>>>>> FALSE)
>>>>> pwAligned<-
>>>>> pairwiseAlignment(c(pattern1,pattern2),c(subject1,subject2),substitutionMatrix=mat,type="local") 
>>>>>
>>>>>
>>>>> ##This throws an error message:
>>>>> ##as.character(pwAligned[1])
>>>>> ##how to make pwAligned[1] a PairwiseAlignedFixedSubject?
>>>>>
>>>>>
>>>>>> sessionInfo()
>>>>> R version 2.12.0 Under development (unstable) (2010-04-07 r51635)
>>>>> x86_64-unknown-linux-gnu
>>>>>
>>>>> locale:
>>>>> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>>>>> [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>>>>> [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>>>>> [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>>>>> [9] LC_ADDRESS=C               LC_TELEPHONE=C
>>>>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>>>>
>>>>> attached base packages:
>>>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>>>
>>>>> other attached packages:
>>>>> [1] BSgenome.Hsapiens.UCSC.hg19_1.3.16 BSgenome_1.17.6
>>>>> [3] Biostrings_2.17.26                 GenomicRanges_1.1.19
>>>>> [5] IRanges_1.7.15
>>>>>
>>>>> loaded via a namespace (and not attached):
>>>>> [1] Biobase_2.9.0 tools_2.12.0
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Stefan Bentink
>>>>> Research Fellow
>>>>> Department of Biostatistics and
>>>>> Computational Biology
>>>>> Dana-Farber Cancer Institute
>>>>> 44 Binney St.
>>>>> Boston, MA 02115
>>>>>
>>>>> Tel: (+1) 617-582-7604
>>>>> Fax: (+1) 617-582-7760
>>>>>
>>>>> bentink at jimmy.harvard.edu
>>>>> http://www.hsph.harvard.edu/research/stefan-bentink/
>>>>>
>>>>> _______________________________________________
>>>>> Bioc-sig-sequencing mailing list
>>>>> Bioc-sig-sequencing at r-project.org
>>>>> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
>>>>>
>>>> _______________________________________________
>>>> Bioc-sig-sequencing mailing list
>>>> Bioc-sig-sequencing at r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
>>>
>>
>>
>


-- 
Stefan Bentink
Research Fellow
Department of Biostatistics and
Computational Biology
Dana-Farber Cancer Institute
44 Binney St.
Boston, MA 02115

Tel: (+1) 617-582-7604
Fax: (+1) 617-582-7760

bentink at jimmy.harvard.edu
http://www.hsph.harvard.edu/research/stefan-bentink/



More information about the Bioc-sig-sequencing mailing list