ggbiplot - 如何不在图中使用特征向量

时间:2014-11-28 19:44:22

标签: r ggbiplot

我有一个数据集数据$ cell_line.sva ,其昏暗值为313 11875.

cc.pca <- prcomp(data$cell_line.sva, center = TRUE, scale. = TRUE, retx = TRUE) 
g <- ggbiplot(cc.pca, obs.scale = 1, var.scale = 1, groups = as.factor(cgpResponse), ellipse = TRUE, circle = FALSE)

enter image description here

如何摆脱功能名称? (红色文字)

4 个答案:

答案 0 :(得分:5)

您需要使用varname.size参数来执行此操作。

使用文档中的示例:

data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, 
               groups = wine.class, ellipse = TRUE, circle = TRUE))

enter image description here

然后添加varname.size参数:

print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, 
               groups = wine.class, ellipse = TRUE, circle = TRUE,
               varname.size=0)) #set it to zero

enter image description here

你有你想要的东西!

答案 1 :(得分:5)

我无法发表评论,因为我还没有获得必要的声誉点,但是通过将 srcRange.Copy Destination:=fillRange 设置为false,可以轻松删除箭头和名称:

var.axes

答案 2 :(得分:4)

我无法弄清楚这会产生什么有用的结果,但无论如何都要进行。这些名称不是函数允许您通过参数设置来抑制的,至少在我阅读代码和帮助页面时是这样。因此,查看代码时,看起来好像因子的标签是从prcomp对象的$ rotations元素中提取的。试图将这些名称全部设置为空白字符会产生错误,因此我成功设置了不同长度的空白值。

data(wine)    # need a reproducible example so use the help page 
 wine.pca <- prcomp(wine, scale. = TRUE)
print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, ellipse = TRUE, circle = TRUE))
# that was the equivalent of your plot
# Now change the input value

dimnames(wine.pca$rotation)[[1]] <- 
   Reduce(function(x,y) paste0(x,y),    # function to concatentate the lanks
          rep(" ",dim(wine.pca$rotation)[1]),   # corrrect number of blanks
           acc=TRUE)                    # save all intermediate strings
 print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, 
        ellipse = TRUE, circle = TRUE))
 #Look, Ma! No labels

enter image description here

答案 3 :(得分:0)

好,所以我以一种非常粗暴的方式来完成这项工作。

    print(ggbiplot(wine.pca, obs.scale = 1, var.scale = 1,
           groups = wine.class, ellipse = TRUE, circle = TRUE,
           varname.size=0, varname.adjust = 20))

它只是为变量名称设置超出绘图限制的偏移量。