R 如何避免ggolot中的不等号错误

R 如何避免ggolot中的不等号错误,r,ggplot2,R,Ggplot2,我试图绘制一个散点图,但我得到了以下错误: 显示对象时出错:错误:美学长度必须为1或与数据(463)相同:标签,x和y 我的代码是: library(ggplot2) library(ggrepel) #Data fig5cwithoutdesc <- read.csv(url("https://raw.githubusercontent.com/learnseq/learning/main/fig5cwithoutdesc.txt"),sep = '\t',head

我试图绘制一个散点图,但我得到了以下错误:

显示对象时出错:错误:美学长度必须为1或与数据(463)相同:标签,x和y

我的代码是:

library(ggplot2)
library(ggrepel)

#Data
fig5cwithoutdesc <- read.csv(url("https://raw.githubusercontent.com/learnseq/learning/main/fig5cwithoutdesc.txt"),sep = '\t',header = TRUE)

attach(fig5cwithoutdesc)

ids <- c("RPL31", "HSPB1", "MAFB", "ALPL1", "VGF","PCSK1N", "BSG", "CALY", "B2M", "SCG5", "TM4SF4")

ggplot(fig5cwithoutdesc,aes(a_donor, a_cell, color=(fig5cwithoutdesc[,1] %in% ids)))+
  geom_point()+
  scale_color_manual(values = c('gray','blue')) +
  geom_text_repel(data=subset(fig5cwithoutdesc,fig5cwithoutdesc[,1] %in% ids),
            aes(label=geneIDs),force=19) +
  theme_bw()+
  theme(legend.position = 'none')

库(ggplot2)
图书馆(ggrepel)
#资料

图5在没有desc的情况下,最好使用变量名,而不是
ggplot2
中的列:

library(ggplot2)
library(ggrepel)

#Data
fig5cwithoutdesc <- read.csv(url("https://raw.githubusercontent.com/learnseq/learning/main/fig5cwithoutdesc.txt"),sep = '\t',header = TRUE)
fig5cwithoutdesc$geneIDs <- trimws(gsub('[[:punct:] ]+',' ',fig5cwithoutdesc$geneIDs))
ids <- c("RPL31", "HSPB1", "MAFB", "ALPL1", "VGF","PCSK1N", "BSG", "CALY", "B2M", "SCG5", "TM4SF4")

ggplot(fig5cwithoutdesc,
       aes(a_donor, a_cell, color=(geneIDs %in% ids)))+
  geom_point()+
  scale_color_manual(values = c('gray','blue')) +
  geom_text_repel(data=subset(fig5cwithoutdesc,geneIDs %in% ids),
                  aes(x=a_donor, y=a_cell,label=geneIDs),force=19) +
  theme_bw()+
  theme(legend.position = 'none')
库(ggplot2)
图书馆(ggrepel)
#资料

图5C不用说明谢谢@Duck,这条线有什么好处
fig5cwithoutdesc$geneIDs@user432797它删除字符串中的任何特殊字符,以便启用过滤器!我找到了缺失的值,它们大约是10K,但我仍然没有得到灰点,这是链接: