如何使用 xlim 或 ylim 停止 ggrepel 重叠点

How to stop ggrepel overlapping points using xlim or ylim

我真的很难理解可能是非常简单的图形。

在 R 中为我的火山图使用以下代码:

> vol+geom_label_repel(data = subset(data, color=="Increased"), aes(label=gene))

我得到如下图片:

但是,如果我尝试使用 xlim 将标签限制在右上象限:

vol+geom_label_repel(data = subset(data, color=="Increased"), aes(label=gene), xlim = c())

无论我输入什么 xlim 或 ylim 值,也不管它在代码中的位置,我都会收到以下错误:

Warning: Ignoring unknown parameters: xlim

谁能建议我如何让 ggrepel 将标签放置在不与右上象限中的点重叠的位置?

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] bindrcpp_0.2               readr_1.1.1                DESeq2_1.16.1              SummarizedExperiment_1.6.3
 [5] DelayedArray_0.2.7         matrixStats_0.52.2         Biobase_2.36.2             GenomicRanges_1.28.5      
 [9] GenomeInfoDb_1.12.2        IRanges_2.10.3             S4Vectors_0.14.4           BiocGenerics_0.22.0       
[13] ggrepel_0.6.5              dplyr_0.7.3                ggplot2_2.2.1             

loaded via a namespace (and not attached):
 [1] httr_1.3.1              tidyr_0.7.1             viridisLite_0.2.0       bit64_0.9-7            
 [5] jsonlite_1.5            splines_3.4.1           Formula_1.2-2           assertthat_0.2.0       
 [9] latticeExtra_0.6-28     blob_1.1.0              cellranger_1.1.0        GenomeInfoDbData_0.99.0
[13] RSQLite_2.0             backports_1.1.0         lattice_0.20-35         glue_1.1.1             
[17] digest_0.6.12           RColorBrewer_1.1-2      XVector_0.16.0          checkmate_1.8.3        
[21] colorspace_1.3-2        htmltools_0.3.6         Matrix_1.2-11           plyr_1.8.4             
[25] XML_3.98-1.9            pkgconfig_2.0.1         genefilter_1.58.1       zlibbioc_1.22.0        
[29] purrr_0.2.3             xtable_1.8-2            scales_0.5.0            BiocParallel_1.10.1    
[33] htmlTable_1.9           tibble_1.3.4            annotate_1.54.0         nnet_7.3-12            
[37] lazyeval_0.2.0          readxl_1.0.0            survival_2.41-3         magrittr_1.5           
[41] memoise_1.1.0           foreign_0.8-69          tools_3.4.1             data.table_1.10.4      
[45] hms_0.3                 stringr_1.2.0           plotly_4.7.1            munsell_0.4.3          
[49] locfit_1.5-9.1          cluster_2.0.6           AnnotationDbi_1.38.2    compiler_3.4.1         
[53] rlang_0.1.2             grid_3.4.1              RCurl_1.95-4.8          htmlwidgets_0.9        
[57] labeling_0.3            bitops_1.0-6            base64enc_0.1-3         gtable_0.2.0           
[61] DBI_0.7                 R6_2.2.2                gridExtra_2.3           knitr_1.17             
[65] bit_1.1-12              bindr_0.1               Hmisc_4.0-3             stringi_1.1.5          
[69] Rcpp_0.12.12            geneplotter_1.54.0      rpart_4.1-11            acepack_1.4.1 

这里是 xlimylimgeom_label_repel 中的使用示例:

library(ggplot2)
library(ggrepel)
set.seed(1)
iris2 <- iris[sample(1:nrow(iris), 20),]
ggplot(iris2, aes(x=Sepal.Length,y=Sepal.Width)) +
geom_point() + 
geom_label_repel(aes(label=Species), xlim=c(6,8), ylim=c(3.2,4))