- 已编辑
我想处理一些DNA的数据,并把它们缩小了一千倍进行分析和绘图,处理5000K的序列没有什么问题,当长度大于6000K时就会报错,我想请问一下解决这样的问题只能是我把数据点继续缩小一下吗,有没有其他办法?
library(Biostrings)
library(BiocGenerics)
library(stats4)
library(S4Vectors)
library(IRanges)
library(XVector)
library(seqinr)
library(parallel)
library(ggplot2)
library(reshape2)
seq<-readDNAStringSet(file.choose())
seq1<-as.character(seq)
seq2<-getSequence(seq1)
a<-cumsum(seq2=="A")
g<-cumsum(seq2=="G")
t<-cumsum(seq2=="T")
c<-cumsum(seq2=="C")
x<-a+g-c-t
y<-a+c-g-t
#z<-a+t-g-c
#处理数据,减少1000倍
len<-floor(length(seq2)/1000)*1000
tpa<-matrix(a[1:len],ncol = 1000,byrow = TRUE)
tpc<-matrix(c[1:len],ncol = 1000,byrow = TRUE)
tpt<-matrix(t[1:len],ncol = 1000,byrow = TRUE)
tpg<-matrix(g[1:len],ncol = 1000,byrow = TRUE)
#绘图数据
aa<-rowSums(tpa)/1000
cc<-rowSums(tpc)/1000
tt<-rowSums(tpt)/1000
gg<-rowSums(tpg)/1000
xlab<-c(1:length(aa))
tpAT<-aa-tt
tpGC<-gg-cc
tpname<-getName.SeqFastadna(seq1)
plot_data<-data.frame(var1=tpGC,var2=tpAT,xlab=xlab)
plot_data_long<-melt(plot_data,id="xlab")
ggplot(data = plot_data_long,aes(x=xlab,y=value,color=variable))+
geom_line()+
theme_gray()+xlab("n(kb)")+
ylab("Base disparity")+
labs(color=NULL)+
scale_color_discrete(labels=c("GC disparity","AT disparity"))+
theme(legend.position = c(1,1),legend.justification = c(1,1))+
theme(legend.background = element_blank())+
theme(legend.key = element_blank())+
ggtitle(tpname)
Error: cannot allocate vector of size 64.0 Mb