R語(yǔ)言地圖展示有多強(qiáng)大呢塘安?
上周基本上完成了地圖展示之后,我探索了一下Rice_3K【3】的數(shù)據(jù)。
先貼上結(jié)果吧跨晴。
具體的過程還是有很多坑的、片林、端盆、怀骤、、焕妙、
先是輕輕松松找到了Rice_3K的數(shù)據(jù)蒋伦。得到數(shù)據(jù)之后只有國(guó)家和地區(qū),但是呢沒有具體的經(jīng)緯度焚鹊,怎么辦呢痕届?
先是想到了用國(guó)家的首都的經(jīng)緯度來(lái)代表國(guó)家的經(jīng)緯度,好吧末患,說(shuō)干就干吧研叫。
首先找國(guó)家的首都就找到崩潰,還感動(dòng)自己說(shuō)大晚上的還在加班璧针。結(jié)果呢嚷炉,Google一下,全球的大多數(shù)國(guó)家和地區(qū)的信息都有了探橱,包括了經(jīng)緯度(數(shù)據(jù)見文末)申屹。一個(gè)VLOOKUP函數(shù)就搞定了。再把沒有信息的那些數(shù)據(jù)刪除隧膏,就得到了clean_data哗讥。下一步,直接Run R Code就完事了私植。
如果需要很詳細(xì)的經(jīng)緯度忌栅, 那有兩個(gè)網(wǎng)站選擇:
【國(guó)外地理位置】
【國(guó)內(nèi)地理位置】
代碼如下:
rm(list = ls())
#加載需要的包
library(ggplot2)
library(maps)
#數(shù)據(jù)加載
data <- read.table("3k_data.txt",header = T)
#創(chuàng)建空的地圖
mp <- NULL
#創(chuàng)建一個(gè)世界地圖
worldmap <- borders("world",colour = "gray50", fill = "cornsilk")
mp <- ggplot() + worldmap + ylim(-90,90) + xlim(-180,180)
map <- mp +
geom_point(aes(x = data$Longitude, y = data$Latitude, color = data$group), size = 4)+
scale_size(range = c(2, 9))+
ggtitle("")+
theme_classic(base_size = 16)+
theme(axis.line = element_blank(),
axis.title= element_blank(),
axis.text= element_blank(),
axis.ticks= element_blank(),
plot.subtitle = element_text(vjust = 1),
plot.caption = element_text(vjust = 1),
plot.title = element_text(hjust = 0.5),
panel.grid.major = element_line(linetype = "blank"),
panel.grid.minor = element_line(linetype = "blank"),
panel.background = element_rect(fill = NA, color = "black", size = 1),
legend.title = element_blank(),
legend.background = element_rect(color = "white"),
legend.position = c(0.1,0.35),
legend.key.height = unit(1,"cm"),
legend.box.background = element_blank(),
legend.key = element_rect(color = "white"),
legend.text = element_text(size = 15))
#查看地圖
map
#保存地圖(不同文件格式)
for (i in 1:3) {
file_types <- c(".pdf",".jpeg",".tiff")
FileName <- paste("Samples Distribution of Rice_3K", file_types[i], sep = "")
ggsave(FileName, width = 15, height = 12)
}
【1】The Power of Inbreeding: NGS-Based GWAS of Rice Reveals Convergent Evolution during Rice Domestication
【2】NRT1.1B is associated with root microbiota composition and nitrogen use in field-grown rice
【3】Genomic variation in 3,010 diverse accessions of Asian cultivated rice
【4】本文相關(guān)數(shù)據(jù)GitHub鏈接