Question: How to combine sequences from different stringsets?
0
gravatar for reubenmcgregor88
11 months ago by
reubenmcgregor880 wrote:

I have imported 2 sets of sequences in fasta format and imported them as DNAStringSets using decipher (which I believe uses biostrings for the basic manipulation of nucleic acts string sets):

> extraemm_DNA_untrim1

A DNAStringSet instance of length 5
    width seq                                                 names               
[1]   346 GCATCCGTAGCGGTCGCTGTGGCT...AAGATGTAGAACGTCACTATCTTA EMM88 emm88.0 (em...
[2]   391 GCATCAGTAGCGGTTGCTTTGACT...AATTAGCGGATAAGCAAGAACATC EMM225 emm225.0 (...
[3]   499 GGTACTGCTTCAGTAGCGGTTGGT...AAGAAGCAGAGCAGAAAAAACTTA EMM52 emm52.0 (em...
[4]   360 GCATCCGTAGCAGTCGCTGTGGCT...GAACGCCAAAGTCAACGAGAAGTC EMM2 emm2.0 (emm-...
[5]   384 AGCAGTTGCTGTGGCTGTTTTAGG...AATAGACAAGCGTTATCAAGAACA EMM114 emm114.0 (...
> extraemm_DNA_untrim2

A DNAStringSet instance of length 5
    width seq                                                 names               
[1]   345 CATCCGTAGCGGTCGCTGTGGCTG...AAGATGTAGAACGTCACTATCTTA EMM88 emm88.0 (em...
[2]   390 CATCAGTAGCGGTTGCTTTGACTG...AATTAGCGGATAAGCAAGAACATC EMM225 emm225.0 (...
[3]   498 GTACTGCTTCAGTAGCGGTTGGTT...AAGAAGCAGAGCAGAAAAAACTTA EMM52 emm52.0 (em...
[4]   359 CATCCGTAGCAGTCGCTGTGGCTG...GAACGCCAAAGTCAACGAGAAGTC EMM2 emm2.0 (emm-...
[5]   383 GCAGTTGCTGTGGCTGTTTTAGGA...AATAGACAAGCGTTATCAAGAACA EMM114 emm114.0 (...
 

Very simply I would like to get a new DNAStringSet with sequences 1 and 2 from extraemm_DNA_untrim1  and 3, 4 and 5 from extraemm_DNA_untrim2.

I realise this is probably a very simple question, but I can not find much simple documentation on Biostrings basics and I am quite new to using it.

Thanks

decipher biostrings • 276 views
ADD COMMENTlink modified 11 months ago by Mike Smith3.2k • written 11 months ago by reubenmcgregor880
Answer: How to combine sequences from different stringsets?
2
gravatar for Mike Smith
11 months ago by
Mike Smith3.2k
EMBL Heidelberg / de.NBI
Mike Smith3.2k wrote:

You can select entries in a DNAStringSet using the [] notation, and you can combine DNAStringSets using c(). So if you want to select the first two entries from one, entries 3 to 5 from the other and then combine you can do:

c( extraemm_DNA_untrim1[1:2], extraemm_DNA_untrim2[3:5] )

Here's a little toy example:

> ## create two BStringSets
> bs1 <- BStringSet(c("A1", "A2", "A3", "A4"))
> bs2 <- BStringSet(c("B1", "B2", "B3", "B4"))
> 
> ## Print them out so we can see the contents
> bs1
  A BStringSet instance of length 4
    width seq
[1]     2 A1
[2]     2 A2
[3]     2 A3
[4]     2 A4
> bs2
  A BStringSet instance of length 4
    width seq
[1]     2 B1
[2]     2 B2
[3]     2 B3
[4]     2 B4
> 
> ## combine first two entries from one, last two from the other
> c(bs1[1:2], bs2[3:4])
  A BStringSet instance of length 4
    width seq
[1]     2 A1
[2]     2 A2
[3]     2 B3
[4]     2 B4
ADD COMMENTlink written 11 months ago by Mike Smith3.2k

Strange, I did try something similar and it combined the DNA from all the selected sequences into one long string, but I can not remember how I managed that.

Thanks for this answer

ADD REPLYlink written 11 months ago by reubenmcgregor880
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 356 users visited in the last hour