基于colnames绘制PCA3D图?
Draw PCA3D plot based on colnames?
我有一个 table 的打击:我可以根据下面的推荐绘制简单的 2 维 PCA 图,但我想要基于 col-names 的 3D PCA?
4_rep1 4_rep2 8_rep1 8_rep2 7_rep1 7_rep2 3_rep1 3_rep2
ENSG00000000003 2202 1787 2357 2257 945 977 1362 8536
ENSG00000000005 33 15 13 12 21 37 20 15
ENSG00000000419 557 442 696 679 359 398 279 314
ENSG00000000457 343 251 218 215 212 219 221 254
ENSG00000000460 276 242 189 202 123 126 206 218
plotPCA(newSeqExpressionSet(as.matrix(data),col=colors))
提前感谢您的任何建议!
假设你需要一个以特征向量为轴,变量的权重为坐标的三维散点图,你可以找到几个选项:
# here the data
results <- data.frame(matrix(c(2202,33,557,1787,15,442,2357,13,696,2257,12,679),nrow=3,ncol=4))
colnames(results) <- c("4_rep1","4_rep2","8_rep1","8_rep2")
rownames(results) <- c("ENSG00000000003","ENSG00000000005","ENSG00000000419")
# then a small transformation
library(data.table)
t_results <- transpose(results)
colnames(t_results) <- rownames(results)
rownames(t_results) <- colnames(results)
#lastly the plot
library(scatterplot3d)
scatterplot3d(t_results[,1],t_results[,2],t_results[,3], main="Very simple")
更酷一点:
library(rgl)
plot3d(results[,1] ,results[,2],results[,3], col="red", size=3)
还有这个:
p <- plot_ly(t_results, x = ~ENSG00000000003, y = ~ENSG00000000005, z = ~ENSG00000000419) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'ENSG00000000003'),
yaxis = list(title = 'ENSG00000000005'),
zaxis = list(title = 'ENSG00000000419')))
p
我有一个 table 的打击:我可以根据下面的推荐绘制简单的 2 维 PCA 图,但我想要基于 col-names 的 3D PCA?
4_rep1 4_rep2 8_rep1 8_rep2 7_rep1 7_rep2 3_rep1 3_rep2
ENSG00000000003 2202 1787 2357 2257 945 977 1362 8536
ENSG00000000005 33 15 13 12 21 37 20 15
ENSG00000000419 557 442 696 679 359 398 279 314
ENSG00000000457 343 251 218 215 212 219 221 254
ENSG00000000460 276 242 189 202 123 126 206 218
plotPCA(newSeqExpressionSet(as.matrix(data),col=colors))
提前感谢您的任何建议!
假设你需要一个以特征向量为轴,变量的权重为坐标的三维散点图,你可以找到几个选项:
# here the data
results <- data.frame(matrix(c(2202,33,557,1787,15,442,2357,13,696,2257,12,679),nrow=3,ncol=4))
colnames(results) <- c("4_rep1","4_rep2","8_rep1","8_rep2")
rownames(results) <- c("ENSG00000000003","ENSG00000000005","ENSG00000000419")
# then a small transformation
library(data.table)
t_results <- transpose(results)
colnames(t_results) <- rownames(results)
rownames(t_results) <- colnames(results)
#lastly the plot
library(scatterplot3d)
scatterplot3d(t_results[,1],t_results[,2],t_results[,3], main="Very simple")
更酷一点:
library(rgl)
plot3d(results[,1] ,results[,2],results[,3], col="red", size=3)
还有这个:
p <- plot_ly(t_results, x = ~ENSG00000000003, y = ~ENSG00000000005, z = ~ENSG00000000419) %>%
add_markers() %>%
layout(scene = list(xaxis = list(title = 'ENSG00000000003'),
yaxis = list(title = 'ENSG00000000005'),
zaxis = list(title = 'ENSG00000000419')))
p