<p>Without giving away too much for your homework check out the <a href="http://www.rexamples.com/14/Sample()" rel="nofollow noreferrer"><code>sample()</code> function in R</a>. Think about how you can pass DNA bases to this function to generate random sequences. </p>

CC BY-SA 4.0
2018-10-13T22:16:26.330Z
Thanks this is really helpful. Can you please help me understand the prob parameter, as I understand the probability of each element is relative to the entire list. Is it possible to specify probabilities for each element in certain positions? say I have `sample(1:2, size=4, replace=TRUE, prob=c(0.8, 0.2))` This says that 1 has probability 0.8 is the list overall, but I want to say 1 has probability 0.8 in position 4 (and some other probability in other positions)
EvaD
CC BY-SA 4.0
2018-10-13T23:47:13.003Z
This can't be done using just the `prob` parameter, because it only takes a single vector as input. You'll have to find some loopy, or otherwize crazy way *for* trying to *apply* different probabilities at different positions.
gringer
CC BY-SA 4.0
2018-10-13T19:54:54.293Z
2018-10-13T19:54:54.293Z
conchoecia
<p>Looking for some guidance.</p>

<p>In an introductory bioinformatics class I am tasked with doing the following in R:</p>

<ol>
<li>Create the sequence ACTGACTG</li>
<li>Generate a random string of nucleotides with equal probabilities.</li>
</ol>

<p>Are there certain functions that I should be looking at? No library or package or set of functions was provided so I am completely lost. I am assuming there must be functions in R that do these things that I need to manipulate, but I cannot seem to find any resources explaining that. I looked at seq() (thinking it might generate DNA sequences), but it only seems to generate sequences of integers. I also looked at randDNA(), but it is random, how could I make it generate the exact string in question 1).</p>

<p>Any direction will be greatly appreciated.
Thanks.</p>

CC BY-SA 4.0
2018-10-14T14:01:23.200Z
They are two separate problems.  If you have something that generates sequences of random integers can you think of a way to map those to the bases you want to report.  The first question is ambiguous.  How do your report the sequence you created?
Bioathlete
<genome-sequencing><homework>
Generating basic dna sequences in R
# Generating basic dna sequences in R

(Asked by: username_0 on 2018-10-13)

Looking for some guidance.

In an introductory bioinformatics class I am tasked with doing the following in R:

1. Create the sequence ACTGACTG
2. Generate a random string of nucleotides with equal probabilities.

Are there certain functions that I should be looking at? No library or package or set of functions was provided so I am completely lost. I am assuming there must be functions in R that do these things that I need to manipulate, but I cannot seem to find any resources explaining that. I looked at seq() (thinking it might generate DNA sequences), but it only seems to generate sequences of integers. I also looked at randDNA(), but it is random, how could I make it generate the exact string in question 1).

Any direction will be greatly appreciated.
Thanks.

**Tags:** genome-sequencing, homework
> **Comments:**
> **username_1**: They are two separate problems.  If you have something that generates sequences of random integers can you think of a way to map those to the bases you want to report.  The first question is ambiguous.  How do your report the sequence you created?  

---

## 1 answers

### Answer by username_2 on 2018-10-13. Score: 1

Without giving away too much for your homework check out the [`sample()` function in R](http://www.rexamples.com/14/Sample()). Think about how you can pass DNA bases to this function to generate random sequences.

> **Comments:**
> **username_0**: Thanks this is really helpful. Can you please help me understand the prob parameter, as I understand the probability of each element is relative to the entire list. Is it possible to specify probabilities for each element in certain positions? say I have `sample(1:2, size=4, replace=TRUE, prob=c(0.8, 0.2))` This says that 1 has probability 0.8 is the list overall, but I want to say 1 has probability 0.8 in position 4 (and some other probability in other positions)  
> **username_3**: This can't be done using just the `prob` parameter, because it only takes a single vector as input. You'll have to find some loopy, or otherwize crazy way *for* trying to *apply* different probabilities at different positions.  

---

