多个标准化变量的小提琴图
我正在尝试使用小提琴图在数据集进行标准化之后将多个样品绘制在多种化合物上。我有一个带有不同样本但具有相同化合物的数据集。我将尝试模拟我的问题:
#数据集的创建
DF1 <-
data.frame(Sample.Name =
c("A1_VAR_B", "A2_VAR_B", "A3_VAR_B", "A4_VAR_B", "A5_VAR_B",
"A6_VAR_B","B1_VAR_B", "B2_VAR_B", "B3_VAR_B", "B4_VAR_B",
"B5_VAR_B", "B6_VAR_B"),
Compound1 = runif(12,0,100),
Compound2 = runif(12,0,100),
Compound3 = runif(12,0,100),
Compound4 = runif(12,0,100),
Compound5 = runif(12,0,100),
Compound6 = runif(12,0,100),
Compound7 = runif(12,0,100),
Compound8 = runif(12,0,100),
Compound9 = runif(12,0,100),
Compound10 = runif(12,0,100),
Compound11 = runif(12,0,100),
Compound12 = runif(12,0,100))
现在尝试我的第一个归一化方法,
Normalization_MM <- function(x) {
(x - min(x)) / (max(x) - min(x))
}
Data_normalized_TEST <- as.data.frame(lapply(DF1[2:12], Normalization_MM))
Data_normalized_TEST$Sample.Name <- DF1$Sample.Name
Data_normalized_TEST <- Data_normalized_TEST %>%
relocate(Sample.Name, .before = Compound1)
我旨在测试各种归一化方法并绘制它们,以查看如何使用每个归一化功能/方法更改。
TESTT2 <- Data_normalized_TEST %>%
gather(Metabolites, Values, -Sample.Name) %>%
ggplot(aes(Metabolites, Values)) +
geom_violin(adjust = .5)
归一化后,结果根本没有图。而在归一化之前,我可以得到体面的情节。我还想将样本名称和复合名称保留在图中。感谢您的帮助!如果我的解释或插图在某种程度上缺乏,请向我提供反馈,以便在必要时可以更多地解释。
编辑 删除切片功能后,这些地块变得更加清晰。但是,在大于30种化合物的数据集上实施此功能无效。我根本看不到任何阴谋。我该如何解决?
I am trying to plot multiple samples over multiple compounds using the violin plot after normalisation of the dataset. I have a data set with different samples but with same compounds. I will try to simulate my problem:
#Creation of data set
DF1 <-
data.frame(Sample.Name =
c("A1_VAR_B", "A2_VAR_B", "A3_VAR_B", "A4_VAR_B", "A5_VAR_B",
"A6_VAR_B","B1_VAR_B", "B2_VAR_B", "B3_VAR_B", "B4_VAR_B",
"B5_VAR_B", "B6_VAR_B"),
Compound1 = runif(12,0,100),
Compound2 = runif(12,0,100),
Compound3 = runif(12,0,100),
Compound4 = runif(12,0,100),
Compound5 = runif(12,0,100),
Compound6 = runif(12,0,100),
Compound7 = runif(12,0,100),
Compound8 = runif(12,0,100),
Compound9 = runif(12,0,100),
Compound10 = runif(12,0,100),
Compound11 = runif(12,0,100),
Compound12 = runif(12,0,100))
Now I try my first normalisation method
Normalization_MM <- function(x) {
(x - min(x)) / (max(x) - min(x))
}
Data_normalized_TEST <- as.data.frame(lapply(DF1[2:12], Normalization_MM))
Data_normalized_TEST$Sample.Name <- DF1$Sample.Name
Data_normalized_TEST <- Data_normalized_TEST %>%
relocate(Sample.Name, .before = Compound1)
I aim to test various normalisation methods and plot them to see how to change with each normalisation function/method.
TESTT2 <- Data_normalized_TEST %>%
gather(Metabolites, Values, -Sample.Name) %>%
ggplot(aes(Metabolites, Values)) +
geom_violin(adjust = .5)
The outcome is no plots at all after normalisation. Whereas before the normalisation, I can get decent plots. And I would also like to keep sample names and compound names in the plot. I appreciate the help ! Please provide me with feedback if my explanation or illustration was lacking in some way, so I can explain more if necessary.
EDIT
After removing the slice function, the plots became more clear. However, implementing this on a dataset bigger than 30 compounds does not work. I don't see any plots at all. How can I solve for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论