gggenomes icon indicating copy to clipboard operation
gggenomes copied to clipboard

Add GC content function for plot.

Open yzhong005 opened this issue 1 year ago • 0 comments

add a function to manually generate the GC content data.frame, which can easily add into the plot.

require(Biostrings) gc_content<-function (x, seq_id, window) {#x must be a DNAstrings, can take with readDNAstring, cannot be a DNAstringset start<-seq(0,(length(x)-window),window) pick<-function(start){ a<-x[start:(start+window)] return(a) } set<-lapply(start,pick) gc_test<-rowSums(letterFrequency(DNAStringSet(set), c("G", "C")))/window gc_test<-data.frame(seq_id=seq_id,start=start,end=start+window,score=gc_test) return(gc_test)}

an example

seq<-readDNAstring("AA.fasta") gc<-gc_content(seq, seq_id="a",50) gggenomes(genes,seqs=seqs,links = links,feats=gc)+ geom_seq()+ geom_gene()+ geom_link(offset = 0.1)+ geom_wiggle(aes(z=score))

yzhong005 avatar Jun 01 '23 05:06 yzhong005