I have this code that creates a random sequence.
`$seq.mat <- matrix(NA, nrow=20, ncol=2)
colnames(seq.mat) <- c("SmapleID","Sequence")
set.seed(123)
for (i in 1:nrow(seq.mat)) {
seq.mat[i,1] <- paste0("Sample_", i)
seq.mat[i,2] <- paste(sample(c("C","G","A","T"), size=1000, replace =
TRUE), collapse="")
}
seq.mat <- cbind(seq.mat, RNASeq=NA, Seq.Count=NA)`
How can I use these 3? functions together in I guess a "multi-function" to run all at once?
`$DNA.RNA = function(check.string){
grep = grepl("[^ACGT]",seq.mat[1:20,2])
DNAorRNA = ifelse(grep == "FALSE", print("Seq is DNA, converting to
RNA.."), print("Seq is RNA"))
DNAorRNA = as.list(DNAorRNA)
DNAorRNA
}
new.dat = gsub("T", "U", seq.mat[,2])
replaceDNA = function(replDNA){
seq.mat[,3] = new.dat
}`
I wanted to put "new.dat" into a function (that's why I said 3 functions) but I had trouble getting the gsub to place the data into seq.mat[,3]. Any way to do that instead and then just combine the 2 functions?
I can run it as a stand alone code but I wanted to put it into one function. If I just add "seq.mat[,3] <- gsub("T","U",seq.mat[,2])" to the original function it doesn't work and the print part only prints one line.