我正在使用ggplot库制作MAPLOT,我希望x轴的比例尺为1,100,10000
我的数据看起来像这样(几行)
gene baseMean log2FoldChange lfcSE stat pvalue padj genename threshold
ENSG00000223972 0.575771350800225 0.0412219472008923 3.00480558248345 0.0137186736610169 0.989054425422109 NA DDX11L1 non_sig
ENSG00000227232 638.915585716581 0.0759771312187909 0.265826656683689 0.285814568661551 0.77502014921445 0.925602441205682 WASH7P non_sig
ENSG00000238009 0.732676980883345 1.70580495308195 2.88536344691496 0.591192404168632 0.554391511600533 NA RP11-34P13.7 sig
ENSG00000233750 0.665119914806497 1.43662798114606 2.40334694948042 0.597761376673745 0.549999165399301 NA CICP27 non_sig
ENSG00000237683 1.61059299708066 1.32385867730769 1.59103144187764 0.832075748135656 0.405366189814378 NA AL627309.1 non_sig
ENSG00000268903 0.53805903280028 1.11220672347871 3.09943388409949 0.358841893413014 0.719713370602976 NA RP11-34P13.15 non_sig
ENSG00000241860 6.36716721142452 1.00072051754609 0.952066011135871 1.0511041312694 0.293210766884749 0.62978967383262 RP11-34P13.13 non_sig
ENSG00000228463 3.16284935240728 2.539009793132 1.21049386749042 2.09749909629516 0.0359494170864793 0.184551759280715 AP006222.2 non_sig
ENSG00000237094 3.57505447485535 -0.402759405190994 0.989965477248915 -0.406841869183409 0.684124133143038 0.887865190354194 RP4-669L17.10 non_sig
我使用了以下R代码:
df <- read.table("test.txt",header=TRUE,sep="\t")
ggplot(df,aes(x=baseMean,y=log2FoldChange)) + geom_point(aes(col=threshold),size=1,shape=20) + ylim(-15,15)+
scale_color_manual(values=c("gray70", "red"), name="threshold")+
scale_x_continuous(trans = 'log10') + geom_hline(yintercept = 0,linetype="dashed",color="red")+ xlab("mean of normalized counts")+
ggtitle("MAPLOT")+theme_classic()
当我在scale_x_continuous中使用log10作为参数时,得到10,1000,100000作为x轴上的标签。有没有办法让我得到1,100,10000作为x轴?
谢谢
答案 0 :(得分:1)
df <- read.table(text = "
gene baseMean log2FoldChange lfcSE stat pvalue padj genename threshold
ENSG00000223972 0.575771350800225 0.0412219472008923 3.00480558248345 0.0137186736610169 0.989054425422109 NA DDX11L1 non_sig
ENSG00000227232 638.915585716581 0.0759771312187909 0.265826656683689 0.285814568661551 0.77502014921445 0.925602441205682 WASH7P non_sig
ENSG00000238009 0.732676980883345 1.70580495308195 2.88536344691496 0.591192404168632 0.554391511600533 NA RP11-34P13.7 sig
ENSG00000233750 0.665119914806497 1.43662798114606 2.40334694948042 0.597761376673745 0.549999165399301 NA CICP27 non_sig
ENSG00000237683 1.61059299708066 1.32385867730769 1.59103144187764 0.832075748135656 0.405366189814378 NA AL627309.1 non_sig
ENSG00000268903 0.53805903280028 1.11220672347871 3.09943388409949 0.358841893413014 0.719713370602976 NA RP11-34P13.15 non_sig
ENSG00000241860 6.36716721142452 1.00072051754609 0.952066011135871 1.0511041312694 0.293210766884749 0.62978967383262 RP11-34P13.13 non_sig
ENSG00000228463 3.16284935240728 2.539009793132 1.21049386749042 2.09749909629516 0.0359494170864793 0.184551759280715 AP006222.2 non_sig
ENSG00000237094 3.57505447485535 -0.402759405190994 0.989965477248915 -0.406841869183409 0.684124133143038 0.887865190354194 RP4-669L17.10 non_sig
",
header = TRUE)
library(ggplot2)
ggplot(df, aes(x = baseMean, y = log2FoldChange)) +
geom_point(aes(col = threshold), size = 1, shape = 20) +
ylim(-15, 15) +
scale_color_manual(values = c("gray70", "red"), name = "threshold") +
scale_x_continuous(trans = "log10", breaks = c(1, 100, 10000), limits = c(NA, 10000)) +
geom_hline(yintercept = 0, linetype = "dashed",color = "red") +
xlab("mean of normalized counts") + ggtitle("MAPLOT") +
theme_classic()