Set library and format

Load data and simple data cleaning

fungal_df = read_excel("/Users/cuihening/Desktop/output/output_results.xlsx", sheet = 4) %>% 
  janitor::clean_names()
stoma_df = read_excel("/Users/cuihening/Desktop/output/output_results.xlsx", sheet = 5) %>% 
  janitor::clean_names()
cell_df = read_excel("/Users/cuihening/Desktop/output/output_results.xlsx", sheet = 6) %>% 
  janitor::clean_names()

Data summary

Fungus table

summary(fungal_df) %>% 
  knitr::kable()
data_identifier fungal_hyphae_id penetration_x penetration_y penetration_z depth_um breadth_um volume_um3 avg_branch_length_um num_branches max_branch_length num_triples num_quads num_terminal above_surface_area_um2 mip_area_um2
Length:888 Min. : 1.00 Min. : -1.00 Min. : -1.00 Min. :-1.0000 Min. : 16.74 Min. : 400 Min. :1.046e+07 Min. : 337.6 Min. : 2.0 Min. : 339.8 Min. : 0.00 Min. : 0.00 Min. : 1.00 Min. : 0 Min. : 1005550
Class :character 1st Qu.: 37.75 1st Qu.: -1.00 1st Qu.: -1.00 1st Qu.:-1.0000 1st Qu.:1753.14 1st Qu.: 1438 1st Qu.:1.381e+07 1st Qu.: 602.4 1st Qu.: 11.0 1st Qu.:1297.9 1st Qu.: 2.00 1st Qu.: 0.00 1st Qu.: 6.00 1st Qu.: 0 1st Qu.: 12474962
Mode :character Median : 74.50 Median : -1.00 Median : -1.00 Median :-1.0000 Median :2069.82 Median : 2288 Median :1.946e+07 Median : 748.8 Median : 15.5 Median :1669.1 Median : 4.00 Median : 1.00 Median : 8.00 Median : 0 Median : 17667650
NA Mean : 74.50 Mean : 25.97 Mean : 12.43 Mean :-0.2027 Mean :2095.47 Mean : 4264 Mean :2.010e+08 Mean : 806.8 Mean : 178.1 Mean :1727.6 Mean : 30.55 Mean : 12.46 Mean : 60.54 Mean : 4490911 Mean : 20373424
NA 3rd Qu.:111.25 3rd Qu.: -1.00 3rd Qu.: -1.00 3rd Qu.:-1.0000 3rd Qu.:2346.00 3rd Qu.: 3185 3rd Qu.:3.548e+07 3rd Qu.: 930.1 3rd Qu.: 26.0 3rd Qu.:2183.0 3rd Qu.: 6.25 3rd Qu.: 3.00 3rd Qu.: 12.25 3rd Qu.: 0 3rd Qu.: 24093388
NA Max. :148.00 Max. :1838.00 Max. :1096.00 Max. :48.0000 Max. :6808.00 Max. :141960 Max. :1.216e+10 Max. :2604.3 Max. :11009.0 Max. :3639.9 Max. :1981.00 Max. :838.00 Max. :4492.00 Max. :330266300 Max. :225889300

Cell table

summary(cell_df) %>% 
  knitr::kable()
data_identifier cell_id centroid_x centroid_y width_um height_um area_um2 eccentricity
Length:1374 Min. : 1 Min. : 66.0 Min. : 34.0 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.3967
Class :character 1st Qu.: 58 1st Qu.: 391.0 1st Qu.: 228.0 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.9281
Mode :character Median :115 Median : 900.0 Median : 982.0 Median :0.0000 Median :0.0000 Median :0.0000 Median :0.9622
NA Mean :115 Mean : 923.4 Mean : 992.2 Mean :0.5502 Mean :0.0393 Mean :0.1509 Mean :0.9339
NA 3rd Qu.:172 3rd Qu.:1401.0 3rd Qu.:1793.0 3rd Qu.:1.0000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.9773
NA Max. :229 Max. :1956.0 Max. :1995.0 Max. :4.0000 Max. :1.0000 Max. :6.2832 Max. :0.9987

Stoma table

summary(stoma_df) %>% 
  knitr::kable()
data_identifier stomate_id centroid_x centroid_y
Length:4230 Min. : 1 Min. : 16.0 Min. : 18
Class :character 1st Qu.:177 1st Qu.: 429.0 1st Qu.: 612
Mode :character Median :353 Median : 892.0 Median :1089
NA Mean :353 Mean : 941.3 Mean :1057
NA 3rd Qu.:529 3rd Qu.:1442.0 3rd Qu.:1524
NA Max. :705 Max. :1998.0 Max. :1996

Feature distribution

Fungus

dep_dis = 
  fungal_df %>% 
  ggplot(aes(x = depth_um)) + 
  geom_density(fill = "#77969A", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$depth_um), linetype = "dotted") +
  labs(x = "Depth") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

brea_dis = 
  fungal_df %>% 
  ggplot(aes(x = breadth_um)) + 
  geom_density(fill = "#CC543A", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$breadth_um), linetype = "dotted") +
  labs(x = "Breadth") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

volu_dis = 
  fungal_df %>% 
  ggplot(aes(x = volume_um3)) + 
  geom_density(fill = "#E9A368", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$volume_um3), linetype = "dotted") +
  labs(x = "Volume") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

avg_branch_dis = 
  fungal_df %>% 
  ggplot(aes(x = avg_branch_length_um)) + 
  geom_density(fill = "#b98b73", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$avg_branch_length_um), linetype = "dotted") +
  labs(x = "Average branch length") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

num_branch_dis = 
  fungal_df %>% 
  ggplot(aes(x = num_branches)) + 
  geom_density(fill = "#cb997e", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$num_branches), linetype = "dotted") +
  labs(x = "Branch number") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

max_branch_dis = 
  fungal_df %>% 
  ggplot(aes(x = max_branch_length)) + 
  geom_density(fill = "#ddbea9", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$max_branch_length), linetype = "dotted") +
  labs(x = "Max Branch length") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

mip_area_dis = 
  fungal_df %>% 
  ggplot(aes(x = mip_area_um2)) + 
  geom_density(fill = "#ddbea9", alpha = 0.6) + 
  geom_vline(xintercept = mean(fungal_df$mip_area_um2), linetype = "dotted") +
  labs(x = "MIP area") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

combination_plt =
  subplot(
    ggplotly(dep_dis),
    ggplotly(brea_dis),
    ggplotly(volu_dis),
    ggplotly(avg_branch_dis),
    ggplotly(num_branch_dis),
    ggplotly(max_branch_dis),
    ggplotly(mip_area_dis),
    nrows = 4,
    titleY = TRUE,
    titleX = TRUE,
    margin = 0.1
  ) 


combination_plt =
  combination_plt %>%
  layout(showlegend = F)

combination_plt

Cell

centx_dis = 
  cell_df %>% 
  ggplot(aes(x = centroid_x)) + 
  geom_density(fill = "#77969A", alpha = 0.6) + 
  geom_vline(xintercept = mean(cell_df$centroid_x), linetype = "dotted") +
  labs(x = "centroid X") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

centy_dis = 
  cell_df %>% 
  ggplot(aes(x = centroid_y)) + 
  geom_density(fill = "#ddbea9", alpha = 0.6) + 
  geom_vline(xintercept = mean(cell_df$centroid_y), linetype = "dotted") +
  labs(x = "centroid Y") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

width_dis = 
  cell_df %>% 
  ggplot(aes(x = width_um)) + 
  geom_density(fill = "#E9A368", alpha = 0.6) + 
  geom_vline(xintercept = mean(cell_df$width_um), linetype = "dotted") +
  labs(x = "Width") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

height_dis = 
  cell_df %>% 
  ggplot(aes(x = height_um)) + 
  geom_density(fill = "#ffe8d6", alpha = 0.6) + 
  geom_vline(xintercept = mean(cell_df$height_um), linetype = "dotted") +
  labs(x = "height") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

area_dis = 
  cell_df %>% 
  ggplot(aes(x = area_um2)) + 
  geom_density(fill = "#d4c7b0", alpha = 0.6) + 
  geom_vline(xintercept = mean(cell_df$area_um2), linetype = "dotted") +
  labs(x = "Area") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

eccen_dis = 
  cell_df %>% 
  ggplot(aes(x = eccentricity)) + 
  geom_density(fill = "#a5a58d", alpha = 0.6) + 
  geom_vline(xintercept = mean(cell_df$eccentricity), linetype = "dotted") +
  labs(x = "Eccentricity") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

combination_cellplt =
  subplot(
    ggplotly(centx_dis),
    ggplotly(centy_dis),
    ggplotly(width_dis),
    ggplotly(height_dis),
    ggplotly(area_dis),
    ggplotly(eccen_dis),
    nrows = 2,
    titleY = TRUE,
    titleX = TRUE,
    margin = 0.1
  ) 


combination_cellplt =
  combination_cellplt %>%
  layout(showlegend = F)

combination_cellplt

Stoma

centx_sdis = 
  stoma_df %>% 
  ggplot(aes(x = centroid_x)) + 
  geom_density(fill = "#77969A", alpha = 0.6) + 
  geom_vline(xintercept = mean(stoma_df$centroid_x), linetype = "dotted") +
  labs(x = "centroid X") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

centy_sdis = 
  stoma_df %>% 
  ggplot(aes(x = centroid_y)) + 
  geom_density(fill = "#d4c7b0", alpha = 0.6) + 
  geom_vline(xintercept = mean(stoma_df$centroid_y), linetype = "dotted") +
  labs(x = "centroid Y") +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45))

combination_stomaplt =
  subplot(
    ggplotly(centx_sdis),
    ggplotly(centy_sdis),
    titleY = TRUE,
    titleX = TRUE,
    margin = 0.1
  ) 


combination_stomaplt =
  combination_stomaplt %>%
  layout(showlegend = F)

combination_stomaplt