当前位置:网站首页>A code takes you to draw multi format sangjimei pictures such as interactive +pdf+png
A code takes you to draw multi format sangjimei pictures such as interactive +pdf+png
2022-07-25 03:20:00 【Liu Yongxin Adam】
Write it at the front
Sangjitu is very nice , It is used to observe the subordinate relationship between different categories , And draw a beautiful structure diagram , Of course, it can be used in many places . Here we use microbiome data phyloseq object , Quickly and easily build a sanggi map for you . So if you have phyloseq Try it directly . The test data in this paper comes from ggClusterNet, Everyone from github Download and use .
actual combat
Import requires R package
library(ggClusterNet)
library(tidyverse)
library(phyloseq)
library(tidyverse)
library(viridis)
library(patchwork)
library(networkD3)
data(ps)We combined microbiological data at genus level , Then take the top 50 genera with the highest abundance , Then remove Unassigned”) %>% vegan_tax() %>% Of microbes . Note that these functions exist in ggClusterNet in , Pay attention to download and installation .
tax = ps %>%
ggClusterNet::tax_glom_wt(ranks = 6) %>%
filter_OTU_ps(50) %>%
subset_taxa(Genus != "Unassigned") %>%
vegan_tax() %>%
as.data.frame()
head(tax)Build connections , A source —- One goal . Mark the labels of different classification levels .
id2 = c("k","p","c","o","f","g")
dat = NULL
for (i in 1:5) {
dat <- tax[,c(i,i+1)] %>% distinct(.keep_all = TRUE)
colnames(dat) = c("source","target")
dat$source = paste(id2[i],dat$source,sep = "_")
dat$target = paste(id2[i+1],dat$target,sep = "_")
if (i == 1) {
dat2 = dat
}
dat2 = rbind(dat2,dat)
}
dim(dat2)
# dat2 = dat2 %>% distinct(.keep_all = TRUE)
head(dat2)Structure abundance table , Here we are only right KO1 This single sample is enriched :
otu = ps %>%
ggClusterNet::tax_glom_wt(ranks = 6) %>%
scale_micro() %>%
filter_OTU_ps(50) %>%
subset_taxa(Genus != "Unassigned") %>%
vegan_otu() %>%
t() %>%
as.data.frame()
head(otu)
otutax = cbind(otu,tax)
id = rank.names(ps)[1:6]
dat = NULL
for (i in 1:6) {
dat <- otutax %>%
group_by(!!sym(id[i])) %>%
summarise(sum(KO1))
colnames(dat) = c("target","value")
dat$target = paste(id2[i],dat$target,sep = "_")
if (i == 1) {
dat3 = dat
}
dat3 = rbind(dat3,dat)
}
dat4 <- dat2 %>% left_join(dat3)
sankey = dat4Construct nodes and connection tables , preservation html file ,pdf and png file .
nodes <- data.frame(name = unique(c(as.character(sankey$source),as.character(sankey$target))),stringsAsFactors = FALSE)
nodes$ID <- 0:(nrow(nodes)-1)
sankey <- merge(sankey,nodes,by.x = "source",by.y = "name")
sankey <- merge(sankey,nodes,by.x = "target",by.y = "name")
colnames(sankey) <- c("X","Y","value","source","target")
sankey <- subset(sankey,select = c("source","target","value"))
nodes <- subset(nodes,select = c("name"))
ColourScal='d3.scaleOrdinal() .range(["#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"])'
sankey$energy_type <- sub(' .*', '', nodes[sankey$source + 1, 'name'])
p <- sankeyNetwork(Links = sankey, Nodes = nodes,
Source = "source",Target = "target",Value = "value",
NodeID = "name",
sinksRight=FALSE,
LinkGroup = 'energy_type',
colourScale= ColourScal,
# nodeWidth=40,
# fontSize=13
# nodePadding=20
)
p
saveNetwork(p,"sankey1.html")
library(webshot)
webshot("sankey.html" , "sankey.png")
webshot("sankey.html" , "sankey.pdf")
Guess you like
iMeta brief introduction Highly quoted articles High color value drawing imageGP Network analysis iNAP
iMeta Web tools Metabolism group MetOrigin Meggie cloud Lactation prediction DeepKla
iMeta review Intestinal flora Plant flora Oral flora Protein structure prediction
10000+: Flora analysis Babies and dogs Rhapsody of syphilis carry DNA Hair Nature
Series of tutorials : Introduction to microbiome Biostar Microbiome Macro genome
Expertise : Academic charts High score article Shengxin Scripture An indispensable person
Article to read : Macro genome Parasite benefits Evolutionary tree Necessary skills : put questions to Search for Endnote
Amplification analysis : Chart interpretation Analysis process Statistical mapping
16S Function prediction PICRUSt FAPROTAX Bugbase Tax4Fun
Biological science : Intestinal bacteria Life on the human body Great leap forward in life Cell warfare The mystery of human body
Written in the back
To encourage readers to communicate and quickly solve scientific research difficulties , We established “ Macro genome ” Discussion groups , There are already domestic and foreign 6000+ Researchers join . Please add editor in chief wechat meta-genomics Bring you into the group , Be sure to remark “ full name - Company - Research direction - The title / grade ”. Please indicate your identity for the senior title , There are also microorganisms at home and abroad PI Cooperation and exchange of group supply . Ask for help with technical problems , First read 《 How to ask questions gracefully 》 Learn how to solve problems , Unresolved intra group discussions , Don't talk about problems in private , Help colleagues .
Click to read the original text , Jump to the latest article catalog to read
边栏推荐
- JS written test question -- promise, setTimeout, task queue comprehensive question
- Database transactions (often asked)
- JS written test questions -- random numbers, array de duplication
- Innobackupex parameter description
- Analysis of cascading relation operation examples of cascade
- MySQL configuration in CDH installation
- How does Jupiter notebook change themes and font sizes?
- Sum of "n" numbers of force deduction summary
- Wechat H5 record
- DOM node type
猜你喜欢

Use of stm32cubemonitor part I - data plotting and instrument display

Eslint error

Calculation method of confusion matrix

File permission management

Learning notes - talking about the data structure and algorithm of MySQL index and the introduction of index

kettle_ Configure database connection_ report errors

JS written test question -- promise, setTimeout, task queue comprehensive question

Learning record 12

Banana pie bpi-m5 toss record (3) -- compile BSP

What is technical support| Daily anecdotes
随机推荐
The relationship between private domain traffic and fission marketing. What is super app? Can our enterprise own it?
Dynamic planning of force buckle punch in summary
Wechat H5 record
Unified return data format
Learning Record V
New features commonly used in ES6
Implementation principle of virtual DOM
Direct insert sort / Hill sort
mysql_ Case insensitive
Hal library serial port for note taking
JS written test question -- prototype, new, this comprehensive question
C language_ Defining structures and using variables
Riotboard development board series notes (V) -- porting u-boot
mysql_ Account authorization permission recycling, account locking and unlocking, account creation and deletion
Stm32cubemx quadrature encoder
Analysis of DNS domain name resolution process
Record once C # extract audio files with ffmempeg
C language_ Structure introduction
Hashcode details
Chrome process architecture