Hello,
Beta-diversity is one of the mostly used analysis method in microbiome community composition study.
Diversity has three kind of scale; Alpha-, Beta-, Gamma-.
What is the difference?
Simply, The group size are getting bigger from Alpha to Gamma.
Alpha diversity is the diversity within a particular area or ecosystem; usually expressed by the number of species (i.e., species richness) in that ecosystem
Beta diversity is a comparison of of diversity between ecosystems, usually measured as the amount of species change between the ecosystems
Gamma diversity is a measure of the overall diversity within a large region. Geographic-scale species diversity according to Hunter (2002: 448)
This is the method the Beta diversity analysis and visualization to 3D plot.
The "rgl" and "car" packages are used in R program.
Let's follow-up the 8 steps below, then you are the professional 3D plot of diversity analysis.
1. Install Packages
############ Packages Install ###########
install.packages("rgl")
install.packages("car")
######################################
2. Launch Packages
############ Launch packages ###########
library("rgl")
library("car")
#######################################
3. Input Dataframe
############## Input Dataframe ###############
data <- read.delim("clipboard", row.names=1) #Copy dataframe from excel and launch command
########################################
4. Calculate Distance
################ Calculate Dist ################
data.dist <- dist(data[,3:359]) # [,3:999] = row from 3 to 999 (bacteria data)
#########################################
5. Calculate Metric Multidimensional Scaling (MDS)
############### Calaulte MDS #################
data.mds <- cmdscale(data.dist, k=3)
#########################################
6. Make x, y, z axis from created data
############## Create x,y,z ################
data.x <- data.mds[,1]
data.y <- data.mds[,2]
data.z <- data.mds[,3]
#########################################
7. Visualization
################### Plot ##################
### i) Observe by monotonic color
scatter3d(data.x,data.y,data.z,
col = "blue",
grid = TRUE,)
### ii) Observe flat surface
scatter3d(data.x,data.y,data.z,
groups = as.factor(data$weight),
grid = TRUE,
)
#data$weight = group named weight in column
### iii) Observe boundary
scatter3d(x = data.x, y = data.y, z = data.z,
groups = as.factor(data$species),
surface=FALSE, ellipsoid = TRUE, grid = FALSE
)
#data$species = group named species in column
############################################
8. Run 3D with video
############## Launch 3D Video ###############
play3d(spin3d(axis=c(0,1,1), rpm=3), duration=30)
############################################
This was the posting about microbiome data to 3D plot visualization with beta diversity analysis.
If you run all command without any error, i give you clap!!
If you are wondering something or error, reply below. I will give you hands.
'R > R_Usage [Eng.]' 카테고리의 다른 글
Heatmap visualization in Rstudio _ high resoultion figure (0) | 2022.11.08 |
---|---|
ANOSIM, Statistical analysis with Rstudio (0) | 2022.11.07 |
Rstudio_ working directory default setting (0) | 2022.11.07 |
Meaning of "header =" in R and colnames default setting (0) | 2022.11.03 |
Computer Task Automation with R program. "KeyboardSimulator" (0) | 2022.11.02 |