全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1522 1
2021-08-31
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
>
这是我的找的代码,但爆出了各种错,大佬们该如何改呢?谢谢

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2021-8-31 14:21:23
这个是我的input数据,也不知道格式有没有错误。
附件列表
捕获.JPG

原图尺寸 39.04 KB

捕获.JPG

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群