I want to sample (random ) nucleic acids at middle 20 positions of DNAstring set
1
0
Entering edit mode
vinod.acear ▴ 50
@vinodacear-8884
Last seen 17 months ago
India

Hi 

I have a DNAStringset as..

A DNAStringSet instance of length 253
      width seq                                                                                                                names               
  [1]   601 TTTAGGATATTGCGGTTAGCATATGGGAATGGAAATAAGATATAATTGTATCATAG...AGAGATGGGCCATGGAGTGAAGTGGAATCTGAGAGTAGGGTAAGTTTGAGATGGT 1_450_1050_-_0
  [2]   601 TTATTTACGATGTACCTGTACATTGTGCAGAAGGTCTTCAGAGTGAGTTTAAGCTA...GAGGGAGCCAATGAGATTTTAAAGGGTATATTACTTATCTTATCGATAAGCAGTA 1_30718_31318_+_4...
  [3]   601 GTGTCGGTGGCACTTCTTTGCAATGTGACAAAAGTATTATTTTGATTGGCGGATTG...GGCACGACCTCCAGAGGGTGATTCAGTAAAAGAGAACAAAAAGGCAAGGAAGAGC 1_41760_42360_+_1...
  [4]   601 GCCATGAACAGGGAAGCAGAATTTGATTCGAAGACTAAGACCAAGCATACCCATTC...TTTCGGCTATCGGAGCCTTTGATTTAATCGCCGGTGCCTACGTCTTTGGTGTGTA 1_70117_70717_-_1...
  [5]   601 ATAAGTTCCACGTTAGTATTGTTGCTATCTGCCTTCCTTCGTAACTTAGTTCCCTA...GTCGTCAATGGTGGGTCTCTTCGGTACGCAACGGTTCAAAATACTCTTGATTAAC 1_124212_124812_-...

 

i want to put random bases at middle 20 positions of this DNAStringSet. Please suggest me some way to do this

.

DNAStringSet sample • 622 views
ADD COMMENT
0
Entering edit mode
@herve-pages-1542
Last seen 6 hours ago
Seattle, WA, United States

Hi,

You can do something along these lines:

library(Biostrings)
dna <- DNAStringSet(c("ACGNACCATG", "ACANAAAATG", "ACGNATTTTT"))
dna
#   A DNAStringSet instance of length 3
#     width seq
# [1]    10 ACGNACCATG
# [2]    10 ACANAAAATG
# [3]    10 ACGNATTTTT

random_nucleotides <- sample(DNA_BASES, length(dna))
random_nucleotides
# [1] "G" "C" "T"

subseq(dna, start=4, width=1) <- random_nucleotides
dna
#   A DNAStringSet instance of length 3
#     width seq
# [1]    10 ACGGACCATG
# [2]    10 ACACAAAATG
# [3]    10 ACGTATTTTT

Cheers,

H.

ADD COMMENT
0
Entering edit mode

Hi Herve Thanks for your support , I think it worked but it had deleted my names attributes. But i had solved that isssue

ADD REPLY
0
Entering edit mode

Good catch! Now fixed in Biostrings 2.38.1 (BioC release) and 2.39.1 (BioC devel). Both versions should become available via biocLite() tomorrow.

Cheers,

H.

ADD REPLY

Login before adding your answer.

Traffic: 210 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6