phyloseq 개체로 그린 plot_richness()에서 가장 큰 이유는 outlier 이 삭제되지 않는다는 것이다.
https://stackoverflow.com/questions/73544659/geom-points-are-not-placed-on-the-boxplot
geom points are not placed on the boxplot?
I don't know how to align the dots to each belong to it is box plot. Why they are appearing like that? I found this post, but it is answering the dodging part which is not part of my code here is my
stackoverflow.com
https://www.biostars.org/p/453046/
How can I remove the outliers from a boxplot and fill the groups?
How can I remove the outliers from a boxplot and fill the groups? 2 2.4 years ago dpc ▴ 240 I have generated these two boxplots: . But I am unable to remove the points and the outliers. I already have used outliers.shape = NA which didn't work. I also wa
www.biostars.org
위 질문글의 그림을 보면, 그래프 상의 outlier 값이 모두 표시되고 있다.
outlier 을 지우기 위한 방법은 오로지 ggplot()으로 바꾸어 그리는것 뿐이다.
🟦 Phyloseq to ggplot
GlobalPatterns데이터를 예시로 들어보자
require("phyloseq")
require("dplyr")
require("ggplot2")
# Load data
data("GlobalPatterns")
plot_richness( )을 이용한 그림
plot_richness(physeq = GlobalPatterns, x = "SampleType", measures="Shannon") +
geom_boxplot(aes(fill = SampleType, color = SampleType),
show.legend = FALSE,alpha=0.5) + # notch = TRUE
theme_classic() +
theme(text = element_text(size = 20),
axis.text.x.bottom = element_text(angle = 90,
hjust = 1,
vjust = 0.5),
legend.title = element_blank())
ggplot( )을 이용한 그림
- phyloseq개체를 data.frame으로 바꾸어 준다
a_div <- estimate_richness(GlobalPatterns, measures = "Shannon")
a_div$SampleID <- row.names(a_div)
a_div <- left_join(a_div,
sample_data(GlobalPatterns),
by = c("SampleID" = "X.SampleID"))
- ggplot()으로 그림그리기
ggplot(a_div,
aes(x = SampleType,
y = Shannon),fill = SampleType) +
geom_boxplot(aes(fill = SampleType, color = SampleType), alpha = 0.3, outliers.shape = NA) +
theme_classic() +
theme(text = element_text(size = 20),
axis.text.x.bottom = element_text(angle = 90,
hjust = 1,
vjust = 0.5),
legend.title = element_blank())
위 샘플은 샘플 수가 많지 않아서 outliers.shape = NA이 적용되지 않았지만
샘플에 표시된 점이 없어진 것을 볼 수 있다.
좀 더 깔끔한 시각화를 위해 노력해보자!