R version 3.6.0
重點(diǎn)在4.yyplot安裝
1.設(shè)置默認(rèn)的國(guó)內(nèi)鏡像地址
從https://mirrors.tuna.tsinghua.edu.cn/CRAN/中添加
原則就是越近越好

2.安裝devtools(支持從github上下載開源的包)
install.packages("devtools")
library(devtools) #先library以后才能用devtools!!
install_github("GuangchuangYu/yyplot")
結(jié)果報(bào)錯(cuò),顯示
ERROR: dependency ‘ggtree’ is not available for package ‘gglayer’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/gglayer’
錯(cuò)誤: Failed to install 'yyplot' from GitHub:
Failed to install 'gglayer' from GitHub:
(由警告轉(zhuǎn)換成)installation of package ‘/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T//RtmptB3H8r/file170cd22121a08/gglayer_0.0.1.tar.gz’ had non-zero exit status
仔細(xì)看錯(cuò)誤提示:dependency ‘ggtree’ is not available for package ‘gglayer’
于是直接到github上搜Y叔(yuguangchang)的ggtree,因?yàn)橄认螺dggtree才能下gglayer
結(jié)果沒搜到Y(jié)叔的ggtree,只搜到gglayer
https://github.com/GuangchuangYu/gglayer

直接把gglayer改成ggtree,成功跳轉(zhuǎn)到Y(jié)叔的ggtree
https://github.com/YuLab-SMU/ggtree

各種嘗試后推薦方法三,因?yàn)榉椒ㄒ欢碚摽尚?,但是?shí)際操作過程中外網(wǎng)速度太慢容易導(dǎo)致下載失敗
方法一:
命令:
devtools::install_git("url")
直接克隆github ggtree的地址,下載ggtree

在Rstudio中輸入命令devtools::install_git("url"),一定記得url上有“ ”,不然會(huì)提示
devtools::install_git(https://github.com/YuLab-SMU/ggtree.git)
錯(cuò)誤: 意外的'/' in "devtools::install_git(https:/"
devtools::install_git("https://github.com/YuLab-SMU/ggtree.git")
方法二:
命令:
devtools::install_github("author/packagesname")
"author/packagesname"在url上直接復(fù)制即可
or:
library(devtools)
install_github("GuangchuangYu/yyplot")

方法三-biomanager安裝ggtree(R>=3.5)-推薦
biomanager的安裝見下方3.
去官網(wǎng)找安裝代碼
http://bioconductor.org/packages/release/bioc/html/ggtree.html
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("ggtree")

wow!安裝成功!并提示是否更新相關(guān)的包

3.安裝biomanager (好處是每半年會(huì)對(duì)R包upgrade&debug)
Bioconductor在R3.5版本以后,終于放棄了source() 這種危險(xiǎn)的鏈接方式,改為用新的安裝方式BiocManager進(jìn)行安裝:
對(duì)于R 3.5 以下的版本,依舊需要使用BiocLite:
代碼已經(jīng)給好,不再需要source():
去官網(wǎng)https://bioconductor.org/install/上查R對(duì)應(yīng)的安裝命令,例如我的是R 3.6,對(duì)應(yīng)bioconductor 3.10

>if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.10")
Bioconductor version 3.10 (BiocManager 1.30.10),
R 3.6.2 (2019-12-12)
Installing package(s) 'BiocVersion'
試開URL’https://bioconductor.org/packages/3.10/bioc/bin/macosx/el-capitan/contrib/3.6/BiocVersion_3.10.1.tgz'
Content type 'application/x-gzip' length 5574 bytes
==================================================
downloaded 5574 bytes
The downloaded binary packages are in
/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T//RtmpH6X08I/downloaded_packages
Bioconductor的 bioc-devel 每六個(gè)月(其實(shí)是每年四月和十月)會(huì)對(duì)旗下的生物相關(guān)的R包進(jìn)行更新和debug,install.packages在很多時(shí)候檢測(cè)不到這些更新,導(dǎo)致使用者總是安裝過時(shí)的版本
4.安裝yyplot-重點(diǎn)
> install_github("GuangchuangYu/yyplot")
>install_github("GuangchuangYu/yyplot")
Downloading GitHub repo GuangchuangYu/yyplot@master
Downloading GitHub repo GuangchuangYu/gglayer@master
Skipping 1 packages not available: ggtree
The downloaded binary packages are in
/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T//RtmpH6X08I/downloaded_packages
錯(cuò)誤: Failed to install 'unknown package' from GitHub:
Failed to install 'gglayer' from GitHub:
Failed to connect to api.github.com port 443: Connection refused
報(bào)錯(cuò):
錯(cuò)誤: Failed to install 'unknown package' from GitHub: Failed to install 'gglayer' from GitHub: Failed to connect to api.github.com port 443: Connection refused
于是單獨(dú)安裝gglayer,先用的biomanager
> BiocManager::install("gglayer")
Bioconductor version 3.10 (BiocManager 1.30.10),
R 3.6.2 (2019-12-12)
Installing package(s) 'gglayer'
Warning message:
package ‘gglayer’ is not available (for R version 3.6.2)
結(jié)果顯示package ‘gglayer’ is not available (for R version 3.6.2)
R3.6不能安裝gglayer?于是跑到Y(jié)叔的github上看支持的R版本,明明支持R>=3.5呀?。?/p>

于是重新用devtools安裝
> devtools::install_github("GuangchuangYu/gglayer")
錯(cuò)誤: Failed to install 'gglayer' from GitHub:
Failed to connect to api.github.com port 443: Connection refused
網(wǎng)絡(luò)問題?于是設(shè)置了代理
git config --global http.proxy http://144.4X.1X.1X:443
再次用devtools安裝...
> devtools::install_github("GuangchuangYu/gglayer")
Skipping install of 'gglayer' from a github remote, the SHA1 (aa7dab85) has not changed since last install.
Use `force = TRUE` to force installation
按照提示來
> devtools::install_github("GuangchuangYu/gglayer",force = TRUE)
> devtools::install_github("GuangchuangYu/gglayer",force = TRUE)
Downloading GitHub repo GuangchuangYu/gglayer@master
Skipping 1 packages not available: ggtree
? checking for file ‘/private/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T/RtmpH6X08I/remotes1737714e28d74/GuangchuangYu-gglayer-aa7dab8/DESCRIPTION’ ...
─ preparing ‘gglayer’:
? checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘gglayer_0.0.1.tar.gz’
* installing *source* package ‘gglayer’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
Registered S3 method overwritten by 'treeio':
method from
root.phylo ape
** testing if installed package keeps a record of temporary installation path
* DONE (gglayer)
wow!gglayer終于安裝成功?。?/p>
于是動(dòng)手再重新安裝yyplot
> devtools::install_github("GuangchuangYu/yyplot")
Downloading GitHub repo GuangchuangYu/yyplot@master
? checking for file ‘/private/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T/RtmpH6X08I/remotes1737726ddd400/GuangchuangYu-yyplot-91d2d33/DESCRIPTION’ ...
─ preparing ‘yyplot’:
? checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘yyplot_0.0.8.tar.gz’
* installing *source* package ‘yyplot’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Error : .onLoad failed in loadNamespace() for 'sysfonts', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: 無法載入共享目標(biāo)對(duì)象‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sysfonts/libs/sysfonts.so’::
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sysfonts/libs/sysfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/sysfonts/libs/sysfonts.so
Reason: image not found
錯(cuò)誤: unable to load R code in package ‘yyplot’
停止執(zhí)行
ERROR: lazy loading failed for package ‘yyplot’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/yyplot’
錯(cuò)誤: Failed to install 'yyplot' from GitHub:
(由警告轉(zhuǎn)換成)installation of package ‘/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T//RtmpH6X08I/file173772d895fef/yyplot_0.0.8.tar.gz’ had non-zero exit status
仔細(xì)看報(bào)錯(cuò)的信息:
Error : .onLoad failed in loadNamespace() for 'sysfonts', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: 無法載入共享目標(biāo)對(duì)
錯(cuò)誤: unable to load R code in package ‘yyplot’
停止執(zhí)行
ERROR: lazy loading failed for package ‘yyplot’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/yyplot’
錯(cuò)誤: Failed to install 'yyplot' from GitHub:
google了Y叔的github yyplot的issue,看有沒有人遇到類似的問題,結(jié)果,確實(shí)mac上有安裝錯(cuò)誤的issue
發(fā)現(xiàn)了類似的問題

有人提出解決方法,下載XQuartz,地址https://www.xquartz.org/

出現(xiàn)的問題叫:
sysfonts not loading/Image not found解答參考https://github.com/yixuan/showtext/issues/13
并重新配置了經(jīng)測(cè)試能登github的proxy
git config --global http.proxy http://10X.1X6.1X5.1X9:443
再次重新安裝yyplot,終于安裝成功!!
> devtools::install_github("GuangchuangYu/yyplot")
Downloading GitHub repo GuangchuangYu/yyplot@master
? checking for file ‘/private/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T/RtmpH6X08I/remotes173776ebf2b1f/GuangchuangYu-yyplot-91d2d33/DESCRIPTION’ ...
─ preparing ‘yyplot’:
? checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘yyplot_0.0.8.tar.gz’
* installing *source* package ‘yyplot’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (yyplot)
6.直接下載packages.tar.gz安裝
install.packages("/Users/quyue/Desktop/adipocyteData/Course/ifnb.SeuratData_3.0.0.tar.gz", repos = NULL, type = "source")
library(ifnb.SeuratData)
說明:原創(chuàng)聲明,部分觀點(diǎn)參考https://zhuanlan.zhihu.com/p/50345757