library(ggpubr)
> inputFile="input.txt" #输入
> outFile="barplot.pdf" #输出
> #读取输入文件,并对输入文件整理
> rt=read.table(inputFile,sep="\t",header=T,check.names=F)
> x=colnames(rt)[2]
> y=colnames(rt)[3]
> colnames(rt)=c("id","Type","Expression")
Error in names(x) <- value :
'names' attribute [3] must be the same length as the vector [1]
> #设置比较组
> group=levels(factor(rt$Type))
> rt$Type=factor(rt$Type, levels=group)
Error in `$<-.data.frame`(`*tmp*`, Type, value = integer(0)) :
替换数据里有0行,但数据有9
> comp=combn(group,2)
Error in combn(group, 2) : n < m
> my_comparisons=list()
> for(i in 1:ncol(comp)){my_comparisons[[i]]<-comp[,i]}#绘制boxplot
Error in ncol(comp) : object 'comp' not found
> boxplot=ggboxplot(rt, x="Type", y="Expression", color="Type",
+ xlab=x,
+ ylab=y,
+ legend.title=x,
+ palette = c("blue","red"),
+ add = "jitter")+
+ stat_compare_means(comparisons = my_comparisons)
Error in `[.data.frame`(data, , x) : 选择了未定义的列
>
> #输出图片
> pdf(file=outFile,width=5,height=4.5)
> print(boxplot)
function (x, ...)
UseMethod("boxplot")
<bytecode: 0x0000026b4c6453a8>
<environment: namespace:graphics>
> dev.off()
null device
1
>
这是我的找的代码,但爆出了各种错,大佬们该如何改呢?谢谢