I am trying to figure out to analyze sepated group of different boxplot from the same matrix and avoid facet_wrap2 (too many data in there) I would like visualize each amino acid independently e.i C8 only, then C8_IS, etc.. or even by group of two amino such as C8+C8_IS and then scroll into Orn + ORN_IS
folling script:
ggboxplot(intensity_test3, x = "sample", y = "Intensity", color = "day", palette = "lancet",
add="jitter", shape = "sample") + facet_grid2(~analyte~conc+method, margins = "vs", scales = "free")+
theme_bw(base_size = 18) +
theme(strip.text.y = element_text(angle = 90)) + scale_y_continuous(labels = function(x) format(x, scientific = TRUE, accuracy = 1))
So I just made up some data to match your graph and code. Here it is:
Just run this code to get the dataset I used.
intensity_test3 <- structure(list(sample = c("Low_qc", "Low_qc", "Low_qc", "Low_qc",
"Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc",
"Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc",
"Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc",
"Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc", "Low_qc",
"high_qc", "high_qc", "high_qc", "high_qc", "high_qc", "high_qc",
"high_qc", "high_qc", "high_qc", "high_qc", "high_qc", "high_qc",
"high_qc", "high_qc", "high_qc", "high_qc", "high_qc", "high_qc",
"high_qc", "high_qc", "high_qc", "high_qc", "high_qc", "high_qc",
"high_qc", "high_qc", "high_qc", "high_qc", "high_qc", "high_qc",
"high_qc", "high_qc"), Intensity = c(1e+05, 1e+05, 1e+05, 1e+05,
1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05,
1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05,
1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05, 1e+05,
1e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05,
2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05,
2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05,
2e+05, 2e+05, 2e+05, 2e+05, 2e+05, 2e+05), day = c("day_1", "day_1",
"day_1", "day_1", "day_2", "day_2", "day_2", "day_2", "day_3",
"day_3", "day_3", "day_3", "day_4", "day_4", "day_4", "day_4",
"day_1", "day_1", "day_1", "day_1", "day_2", "day_2", "day_2",
"day_2", "day_3", "day_3", "day_3", "day_3", "day_4", "day_4",
"day_4", "day_4", "day_1", "day_1", "day_1", "day_1", "day_2",
"day_2", "day_2", "day_2", "day_3", "day_3", "day_3", "day_3",
"day_4", "day_4", "day_4", "day_4", "day_1", "day_1", "day_1",
"day_1", "day_2", "day_2", "day_2", "day_2", "day_3", "day_3",
"day_3", "day_3", "day_4", "day_4", "day_4", "day_4"), analyte = c("C8",
"C8_I6", "orn", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "om", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "orn", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "om", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "orn", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "om", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "orn", "orn_IS", "C8", "C8_I6", "orn", "orn_IS", "C8",
"C8_I6", "om", "orn_IS", "C8", "C8_I6", "orn", "orn_IS"), conc = c(2.7,
2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7,
2.7, 2.7, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1,
8.1, 8.1, 8.1, 8.1, 8.1, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7,
2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 2.7, 8.1, 8.1, 8.1, 8.1, 8.1,
8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1, 8.1), method = c("new",
"new", "new", "new", "new", "new", "new", "new", "new", "new",
"new", "new", "new", "new", "new", "new", "old", "old", "old",
"old", "old", "old", "old", "old", "old", "old", "old", "old",
"old", "old", "old", "old", "new", "new", "new", "new", "new",
"new", "new", "new", "new", "new", "new", "new", "new", "new",
"new", "new", "old", "old", "old", "old", "old", "old", "old",
"old", "old", "old", "old", "old", "old", "old", "old", "old"
)), class = "data.frame", row.names = c(NA, -64L))
Then I made a for loop
and filter
to only run each analyte
. It should print each figure separately. You'' have to use the arrows in your plot viewer to see them as they are generated (assuming you're using R studio). Let me know if you have any questions, or if that's what you were looking for.
for (i in unique(intensity_test3$analyte)){
p <- ggboxplot(intensity_test3 %>% dplyr::filter(analyte %in% c(i)), x = "sample", y = "Intensity", color = "day", palette = "lancet",
add="jitter", shape = "sample") + facet_grid2(~analyte~conc+method, margins = "vs", scales = "free")+
theme_bw(base_size = 18) +
theme(strip.text.y = element_text(angle = 90)) + scale_y_continuous(labels = function(x) format(x, scientific = TRUE, accuracy = 1))
print(p)
}
Here is an example of one figure it made.
EDIT:
You can certainly choose which panels go together. You could just do it like this (simply filter the data you give ggboxplot
):
p1 <- ggboxplot(intensity_test3 %>% dplyr::filter(analyte %in% c("C8", "C8_I6")), x = "sample", y = "Intensity", color = "day", palette = "lancet",
add="jitter", shape = "sample") + facet_grid2(~analyte~conc+method, margins = "vs", scales = "free")+
theme_bw(base_size = 18) +
theme(strip.text.y = element_text(angle = 90)) + scale_y_continuous(labels = function(x) format(x, scientific = TRUE, accuracy = 1))
p2 <- ggboxplot(intensity_test3 %>% dplyr::filter(analyte %in% c("orn", "orn_IS")), x = "sample", y = "Intensity", color = "day", palette = "lancet",
add="jitter", shape = "sample") + facet_grid2(~analyte~conc+method, margins = "vs", scales = "free")+
theme_bw(base_size = 18) +
theme(strip.text.y = element_text(angle = 90)) + scale_y_continuous(labels = function(x) format(x, scientific = TRUE, accuracy = 1))
print(p1)
print(p2)
As for the t-test, this might be better for a separate question on SO or even perhaps the "stats" version of SO, Cross Validated if needed. It sounds like you have multiple factors and I don't know exactly what questions you would want to answer. Making a new post, and taking the time to fully describe what statistics you would like to perform would be most helpful for you.