一口气安装800个R包

我们周末班准备工作主要就是希望大家学会安装R包 http://www.bio-info-trainee.com/3727.html

首先配置中国大陆特色镜像

如果是在海外网络,通常是不需要选择我们这里的代码里面的清华大学和中科院镜像:

options()$repos 
options()$BioC_mirror
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/")
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options()$repos 
options()$BioC_mirror

然后按需安装指定的R包

一般来说,我们做生物信息,下面的包肯定是必不可少。但是需要一个个包去记录,去慢慢安装:

# https://bioconductor.org/packages/release/bioc/html/GEOquery.html
if (!requireNamespace("BiocManager", quietly = TRUE))
 install.packages("BiocManager")
BiocManager::install("KEGG.db",ask = F,update = F)
BiocManager::install(c("GSEABase","GSVA","clusterProfiler" ),ask = F,update = F)
BiocManager::install(c("GEOquery","limma","impute" ),ask = F,update = F)
BiocManager::install(c("org.Hs.eg.db","hgu133plus2.db" ),ask = F,update = F)

实际上,大家即使是没有学习过R包安装,也可以看得懂,变化R包名字,就可以一行行运行代码来安装指定的包了!

批量安装R包而且不重复安装呢?

当然也是有办法的, 我在移植一些shiny应用程序就用到过:

list.of.packages <- c("shiny",
 "tidyr",
 'tidyverse', 
 "clusterProfiler",
 "DT",
 "ashr",
 "enrichplot",
 "plotly")
# 这个 list.of.packages 变量可以是读取一个包名字文件,比如文末的800多个包:
all_packages = rownames(installed.packages())
save(all_packages,file = 'all_packages.Rdata')

#checking missing packages from list
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
new.packages 
packToInst <- setdiff(list.of.packages, installed.packages())
packToInst
if(T){
 lapply(packToInst, function(x){
 BiocManager::install(x,ask = F,update = F)
 })
}
lapply(intersect(packagesReq, installed.packages()),function(x){
 suppressPackageStartupMessages(library(x,character.only = T))
})

其实你有没有发现,代码反而是多了呢?嘻嘻,虽然代码多了,但是确实是好用!

最近我们做了一些服务器共享,需要在上面安装常见的包给用户,这样避免每个人都重复安装同样的包!

其中800多个包,如下所示:

1 abind
2 acepack
3 ade4
4 ADGofTest
5 afex
6 affxparser
7 affy
8 affyio
9 AIMS
10 airway
11 ALL
12 amap
13 AnnoProbe
14 annotate
15 AnnotationDbi
16 AnnotationFilter
17 AnnotationHub
18 ape
19 aplot
20 aroma.light
21 arules
22 arulesViz
23 askpass
24 assertthat
25 backports
26 base
27 base64
28 base64enc
29 base64url
30 BayesFactor
31 bayestestR
32 bbmle
33 bdsmatrix
34 beachmat
35 beanplot
36 beeswarm
37 benchmarkme
38 benchmarkmeData
39 BH
40 bibtex
41 Biobase
42 BiocFileCache
43 BiocGenerics
44 BiocIO
45 BiocManager
46 BiocNeighbors
47 BiocParallel
48 BiocSingular
49 BiocVersion
50 biocViews
51 biomaRt
52 Biostrings
53 biovizBase
54 bit
55 bit64
56 bitops
57 blob
58 bluster
59 boot
60 bootstrap
61 brew
62 bridgesampling
63 brio
64 Brobdingnag
65 broom
66 broom.mixed
67 broomExtra
68 BSgenome
69 bslib
70 bumphunter
71 BWStest
72 ca
73 cachem
74 callr
75 car
76 carData
77 caret
78 caTools
79 ccdrAlgorithm
80 cellranger
81 checkmate
82 ChIPpeakAnno
83 ChIPseeker
84 chron
85 circlize
86 class
87 cli
88 clipr
89 clisymbols
90 CLL
91 clue
92 cluster
93 clusterProfiler
94 ClusterR
95 cmprsk
96 coda
97 codetools
98 coin
99 colorspace
100 colourpicker
101 combinat
102 cometExactTest
103 commonmark
104 compiler
105 ComplexHeatmap
106 conquer
107 ConsensusClusterPlus
108 contfrac
109 copula
110 corpcor
111 correlation
112 corrplot
113 cowplot
114 cpp11
115 crayon
116 credentials
117 crosstalk
118 ctc
119 curl
120 cutoff
121 data.table
122 datasets
123 datawizard
124 DBI
125 dbplyr
126 dbscan
127 DDRTree
128 DelayedArray
129 DelayedMatrixStats
130 deldir
131 dendextend
132 densityClust
133 DEoptimR
134 desc
135 DescTools
136 DESeq2
137 deSolve
138 devtools
139 dichromat
140 diffobj
141 digest
142 diptest
143 discretecdAlgorithm
144 do
145 DO.db
146 docopt
147 doParallel
148 doRNG
149 DOSE
150 dotCall64
151 downloader
152 dplyr
153 dqrng
154 DT
155 dtplyr
156 dynamicTreeCut
157 e1071
158 EDASeq
159 edgeR
160 effectsize
161 egg
162 ellipse
163 ellipsis
164 elliptic
165 emmeans
166 EMT
167 enrichplot
168 EnsDb.Hsapiens.v75
169 ensembldb
170 estimability
171 europepmc
172 evaluate
173 Exact
174 exactRankTests
175 exomeCopy
176 ExperimentHub
177 expm
178 ez
179 factoextra
180 FactoMineR
181 fansi
182 farver
183 fastcluster
184 fastGHQuad
185 fastICA
186 fastmap
187 fastmatch
188 FD
189 FDb.InfiniumMethylation.hg19
190 ff
191 fgsea
192 fields
193 filelock
194 fit.models
195 fitdistrplus
196 flashClust
197 flexmix
198 FNN
199 fontawesome
200 forcats
201 foreach
202 foreign
203 formatR
204 Formula
205 fpc
206 fs
207 furrr
208 futile.logger
209 futile.options
210 future
211 future.apply
212 gameofthrones
213 gapminder
214 gargle
215 gbRd
216 gclus
217 gdata
218 genefilter
219 genefu
220 geneplotter
221 generics
222 genomation
223 GenomeInfoDb
224 GenomeInfoDbData
225 GenomicAlignments
226 GenomicFeatures
227 GenomicRanges
228 geometry
229 GEOquery
230 gert
231 GetoptLong
232 GGally
233 ggbeeswarm
234 ggbio
235 ggcorrplot
236 ggdendro
237 ggExtra
238 ggforce
239 ggfortify
240 ggfun
241 ggnetwork
242 ggplot2
243 ggplotify
244 ggpubr
245 ggraph
246 ggrepel
247 ggridges
248 ggrisk
249 ggsci
250 ggsignif
251 ggstatsplot
252 ggtext
253 ggthemes
254 ggtree
255 gh
256 git2r
257 gitcreds
258 gld
259 glmnet
260 glmSparseNet
261 GlobalOptions
262 globals
263 glue
264 gmodels
265 gmp
266 gnm
267 GO.db
268 goftest
269 googledrive
270 googlesheets4
271 GOplot
272 GOSemSim
273 gower
274 GPArotation
275 gplots
276 graph
277 graphics
278 graphite
279 graphlayouts
280 grDevices
281 grid
282 gridBase
283 gridExtra
284 gridGraphics
285 gridtext
286 GSEABase
287 gsl
288 gsubfn
289 GSVA
290 gtable
291 gtools
292 harrypotter
293 hash
294 haven
295 HDF5Array
296 here
297 hexbin
298 hgu133a.db
299 hgu133a2.db
300 hgu133plus2.db
301 hgu95av2.db
302 highr
303 Hmisc
304 hms
305 howmany
306 HSMMSingleCell
307 htmlTable
308 htmltools
309 htmlwidgets
310 httpuv
311 httr
312 hugene10sttranscriptcluster.db
313 hwriter
314 hypergeo
315 iC10
316 iC10TrainingData
317 ica
318 idr
319 ids
320 igraph
321 illuminaHumanv3.db
322 illuminaio
323 impute
324 ini
325 inline
326 insight
327 InteractionSet
328 interactiveDisplayBase
329 ipred
330 IRanges
331 IRdisplay
332 IRkernel
333 irlba
334 isoband
335 iterators
336 jackstraw
337 jcolors
338 jmv
339 jmvcore
340 jomo
341 jpeg
342 jquerylib
343 jsonlite
344 KEGGREST
345 kernlab
346 KernSmooth
347 km.ci
348 KMsurv
349 knitr
350 kSamples
351 labeling
352 labelled
353 laeken
354 lambda.r
355 LaplacesDemon
356 lars
357 later
358 lattice
359 latticeExtra
360 lava
361 lavaan
362 lazyeval
363 leaps
364 learnr
365 leiden
366 lfa
367 libcoin
368 lifecycle
369 limma
370 linprog
371 listenv
372 lme4
373 lmerTest
374 lmom
375 lmtest
376 locfdr
377 locfit
378 logspline
379 loo
380 loose.rock
381 lpSolve
382 lsei
383 lubridate
384 lumi
385 made4
386 maftools
387 magic
388 magick
389 magrittr
390 manipulate
391 manipulateWidget
392 mapproj
393 maps
394 maptools
395 markdown
396 MASS
397 Matching
398 MatchIt
399 mathjaxr
400 matlab
401 Matrix
402 MatrixGenerics
403 MatrixModels
404 matrixStats
405 maxstat
406 mbkmeans
407 mc2d
408 mclust
409 mcmc
410 MCMCpack
411 memoise
412 memuse
413 metaBMA
414 metafor
415 metap
416 metaplus
417 metapod
418 methods
419 methylumi
420 mets
421 mgcv
422 mice
423 mime
424 minfi
425 miniUI
426 minqa
427 miRNAtap
428 missMDA
429 mitml
430 mitools
431 mlbench
432 mnormt
433 ModelMetrics
434 modelr
435 modeltools
436 monocle
437 multcomp
438 multcompView
439 MultiAssayExperiment
440 multtest
441 munsell
442 mutoss
443 mvnfast
444 mvnormtest
445 mvtnorm
446 network
447 nleqslv
448 nlme
449 nloptr
450 NMF
451 nnet
452 nomogramFormula
453 nor1mix
454 nortest
455 npsurv
456 numDeriv
457 oligo
458 oligoClasses
459 oompaBase
460 openssl
461 openxlsx
462 ordinal
463 org.Dm.eg.db
464 org.Hs.eg.db
465 org.Mm.eg.db
466 org.Rn.eg.db
467 OrganismDbi
468 packrat
469 paletteer
470 palr
471 pals
472 pamr
473 pan
474 pander
475 parallel
476 parallelly
477 parameters
478 patchwork
479 pbapply
480 pbdZMQ
481 pbivnorm
482 pbkrtest
483 pcaMethods
484 pcaPP
485 pd.hugene.2.0.st
486 pdftools
487 pec
488 performance
489 permute
490 pheatmap
491 phylobase
492 pillar
493 pinfsc50
494 pixmap
495 pkgbuild
496 pkgconfig
497 pkgload
498 pkgmaker
499 plogr
500 plotly
501 plotrix
502 plyr
503 PMCMR
504 PMCMRplus
505 png
506 polspline
507 polyclip
508 polynom
509 prabclus
510 pracma
511 praise
512 preprocessCore
513 prettyunits
514 princurve
515 prismatic
516 pROC
517 processx
518 prodlim
519 progress
520 progressr
521 promises
522 ProtGenerics
523 proto
524 proxy
525 ps
526 pspline
527 psych
528 Publish
529 purrr
530 purrrlyr
531 qap
532 qlcMatrix
533 qpdf
534 quadprog
535 quantmod
536 quantreg
537 qvalue
538 qvcalc
539 R.methodsS3
540 R.oo
541 R.utils
542 R6
543 randomForest
544 ranger
545 RANN
546 rappdirs
547 rat2302.db
548 RBGL
549 rbibutils
550 rcmdcheck
551 RColorBrewer
552 rcompanion
553 rcorpora
554 Rcpp
555 RcppAnnoy
556 RcppArmadillo
557 RcppEigen
558 RcppGSL
559 RcppHNSW
560 RcppParallel
561 RcppProgress
562 RcppZiggurat
563 RCurl
564 RCy3
565 Rdpack
566 reactome.db
567 ReactomePA
568 readr
569 readxl
570 recipes
571 regioneR
572 registry
573 relimp
574 rematch
575 rematch2
576 remotes
577 renv
578 repr
579 reprex
580 reshape
581 reshape2
582 restfulr
583 reticulate
584 rex
585 Rfast
586 rgl
587 rhdf5
588 rhdf5filters
589 Rhdf5lib
590 Rhtslib
591 rio
592 riskRegression
593 rJava
594 rjson
595 RJSONIO
596 rlang
597 rmarkdown
598 rmeta
599 Rmpfr
600 rms
601 RnBeads
602 RnBeads.hg38
603 rncl
604 RNeXML
605 rngtools
606 robust
607 robustbase
608 RobustRankAggreg
609 ROCit
610 ROCR
611 rootSolve
612 ROTS
613 roxygen2
614 rpart
615 rprojroot
616 rrcov
617 rsample
618 Rsamtools
619 RSpectra
620 RSQLite
621 rstan
622 rstantools
623 rstatix
624 rstudioapi
625 rsvd
626 RTCGA
627 RTCGA.clinical
628 RTCGA.miRNASeq
629 RTCGA.rnaseq
630 rtracklayer
631 Rtsne
632 RUnit
633 rvcheck
634 rversions
635 rvest
636 rWikiPathways
637 S4Vectors
638 sandwich
639 sass
640 ScaledMatrix
641 scales
642 scater
643 scattermore
644 scatterpie
645 scatterplot3d
646 scico
647 scran
648 scrime
649 scRNAseq
650 sctransform
651 scuttle
652 segmented
653 selectr
654 seqinr
655 seqPattern
656 seriation
657 sessioninfo
658 set
659 Seurat
660 SeuratObject
661 shadowtext
662 shape
663 shiny
664 shinyjs
665 shinythemes
666 ShortRead
667 siggenes
668 SingleCellExperiment
669 sitmo
670 sjlabelled
671 sjmisc
672 sjstats
673 skimr
674 slam
675 slider
676 slingshot
677 smoother
678 sn
679 sna
680 snow
681 softImpute
682 SomaticCancerAlterations
683 SomaticSignatures
684 sourcetools
685 sp
686 spam
687 sparsebn
688 sparsebnUtils
689 SparseM
690 sparseMatrixStats
691 sparsesvd
692 spatial
693 spatstat.core
694 spatstat.data
695 spatstat.geom
696 spatstat.sparse
697 spatstat.utils
698 splines
699 sqldf
700 SQUAREM
701 stabledist
702 StanHeaders
703 statmod
704 statnet.common
705 stats
706 stats4
707 statsExpressions
708 stringi
709 stringr
710 SummarizedExperiment
711 SuppDists
712 survcomp
713 survey
714 survival
715 survivalROC
716 survminer
717 survMisc
718 sva
719 swirl
720 sys
721 table1
722 tableone
723 taRifx
724 TCGAbiolinks
725 TCGAbiolinksGUI.data
726 tcltk
727 tensor
728 testthat
729 TFisher
730 TH.data
731 tibble
732 tidygraph
733 tidyr
734 tidyselect
735 tidytree
736 tidyverse
737 timeDate
738 timereg
739 timeROC
740 tinytex
741 TMB
742 tmcn
743 tmvnsim
744 tools
745 TrajectoryUtils
746 treeio
747 triebeard
748 tsne
749 TSP
750 TTR
751 tweenr
752 TxDb.Dmelanogaster.UCSC.dm3.ensGene
753 TxDb.Dmelanogaster.UCSC.dm6.ensGene
754 TxDb.Hsapiens.UCSC.hg19.knownGene
755 tximport
756 tzdb
757 uchardet
758 ucminf
759 UpSetR
760 urltools
761 usethis
762 utf8
763 utils
764 uuid
765 uwot
766 V8
767 VariantAnnotation
768 vcd
769 vcdExtra
770 vcfR
771 vctrs
772 vegan
773 VennDiagram
774 VGAM
775 VIM
776 vipor
777 viridis
778 viridisLite
779 visNetwork
780 vroom
781 waldo
782 warp
783 webshot
784 WGCNA
785 whisker
786 withr
787 wordcloud
788 WRS2
789 xfun
790 XLConnect
791 XML
792 xml2
793 xopen
794 xtable
795 xts
796 XVector
797 yaml
798 yulab.utils
799 zeallot
800 zinbwave
801 zip
802 zlibbioc
803 zoo

Comments are closed.