Closed:Basic genes codon count in R with seqinr
0
0
Entering edit mode
3.9 years ago
monlawski • 0

Hello everyone, im new to the r and i have some problems. I need to use just seqinr, so my question is ;

I need to read my genes in FASTA into the list genes so it should be like ;

   library(seqinr)
    genes <- read.fasta('geness.txt')
    length(genes)
## [1] 4120

and i can see my number of genes with the length.

but I need to apply codon_count() to each gene and store the results in the list gene_codon_count.

    codon_count <- function(gene) {
  answer <- rep(0, 64)
  names(answer) <- c("aaa", "aac", "aag", "aat", "aca", "acc", "acg", "act",
      "aga",  "agc", "agg", "agt", "ata", "atc", "atg", "att", "caa", "cac", 
      "cag", "cat", "cca", "ccc", "ccg", "cct", "cga", "cgc", "cgg",  "cgt",
      "cta", "ctc", "ctg", "ctt", "gaa", "gac", "gag", "gat",  "gca", "gcc",
      "gcg", "gct", "gga", "ggc", "ggg", "ggt", "gta",  "gtc", "gtg", "gtt",
      "taa", "tac", "tag", "tat", "tca", "tcc",  "tcg", "tct", "tga", "tgc",
      "tgg", "tgt", "tta", "ttc", "ttg",  "ttt")
  for(i in seq(from=1, to=length(gene), by=3)) {
    codon <- tolower(paste0(gene[i], gene[i+1], gene[i+2]))
    answer[codon] <- answer[codon] + 1
  }
  return(answer)
}

and the answer should be

length(genes_codon_count)
## [1] 4120
length(genes_codon_count[[1]])
## [1] 64

But i cant get any results so im missing or doing something wrong.

gene sequence genome • 109 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3131 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