論文是 Whole-genome resequencing of 445 Lactuca accessions reveals the domestication history of cultivated lettuce

這篇論文的數(shù)據(jù)是公開的,我們可以試著用公開的數(shù)據(jù)復(fù)現(xiàn)一下論文中用來展示數(shù)據(jù)的圖。第一個(gè)圖是使用地圖來展示實(shí)驗(yàn)樣本的地理分布。論文中寫道 畫圖是使用ggplot2,作圖數(shù)據(jù)來自 the Natural Earth dataset (http://www.naturalearthdata.com).
The world map was constructed using the R package ggplot2 with the Natural Earth dataset.
(http://www.naturalearthdata.com) 這個(gè)鏈接的數(shù)據(jù)怎么下載暫時(shí)沒有搞明白。查了一下,發(fā)現(xiàn)R語言里有專門的包來獲取這個(gè)地圖數(shù)據(jù),參考鏈接是 https://slcladal.github.io/maps.html
先安裝獲取地圖數(shù)據(jù)的兩個(gè)包
install.packages("rnaturalearth")
install.packages("rnaturalearthdata")
這個(gè)地方還需要安裝rgeos這個(gè)包,要不然會(huì)遇到報(bào)錯(cuò)
Error in st_as_sfc.SpatialPolygons(sp::geometry(x), ...) :
package rgeos required for finding out which hole belongs to which exterior ring

這個(gè)地方我試著用install.packages("rgeos")來安裝沒有成功

然后就直接下載了包的源碼進(jìn)行本地安裝,成功
下載鏈接
https://cran.r-project.org/web/packages/rgeos/index.html


畫地圖
library(ggplot2)
# gene world map
ggplot(data = world) +
geom_sf() +
labs( x = "Longitude", y = "Latitude") +
ggtitle("World map",
subtitle = paste0("(",
length(unique(world$admin)),
" countries)"))

那么應(yīng)該如何給海洋的部分填充藍(lán)色呢?上面提到的鏈接里是直接把背景改成藍(lán)色就好了
library(ggplot2)
# gene world map
ggplot(data = world) +
geom_sf(fill="white") +
labs( x = "Longitude", y = "Latitude") +
# ggtitle("World map",
# subtitle = paste0("(",
# length(unique(world$admin)),
# " countries)"))+
theme_bw()+
theme(#plot.background = element_rect(fill = "aliceblue"),
panel.grid = element_blank(),
panel.background = element_rect(fill = "aliceblue"))+
labs(x=NULL,y=NULL)

這個(gè)圖對應(yīng)的是論文中fig1a中右上角的完整地圖,但是還沒有添加表示取樣地點(diǎn)的點(diǎn)和表示樣本比例的餅圖

- 接下來就是如何添加表示比例的餅圖了
- 如何只顯示部分區(qū)域呢?
這兩個(gè)問題有時(shí)間再來研究吧!
歡迎大家關(guān)注我的公眾號(hào)
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號(hào) 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記;3、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!
-
https://www.datanovia.com/en/blog/how-to-create-a-map-using-ggplot2/
這個(gè)鏈接也是介紹畫地圖的