R devtools安装yyplot(解决了mac安装错误问题)

R version 3.6.0
重点在4.yyplot安装

1.设置默认的国内镜像地址

https://mirrors.tuna.tsinghua.edu.cn/CRAN/中添加
原则就是越近越好

image.png

2.安装devtools(支持从github上下载开源的包)

install.packages("devtools")
library(devtools) #先library以后才能用devtools!!
install_github("GuangchuangYu/yyplot")

结果报错,显示

ERROR: dependency ‘ggtree’ is not available for package ‘gglayer’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/gglayer’
错误: Failed to install 'yyplot' from GitHub:
  Failed to install 'gglayer' from GitHub:
  (由警告转换成)installation of package ‘/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T//RtmptB3H8r/file170cd22121a08/gglayer_0.0.1.tar.gz’ had non-zero exit status

仔细看错误提示:dependency ‘ggtree’ is not available for package ‘gglayer’

于是直接到github上搜Y叔(yuguangchang)的ggtree,因为先下载ggtree才能下gglayer

结果没搜到Y叔的ggtree,只搜到gglayer
https://github.com/GuangchuangYu/gglayer

直接把gglayer改成ggtree,成功跳转到Y叔的ggtree
https://github.com/YuLab-SMU/ggtree

image.png

各种尝试后推荐方法三,因为方法一二理论可行,但是实际操作过程中外网速度太慢容易导致下载失败

方法一:

命令:

devtools::install_git("url")

直接克隆github ggtree的地址,下载ggtree


image.png

在Rstudio中输入命令devtools::install_git("url"),一定记得url上有“ ”,不然会提示

devtools::install_git(https://github.com/YuLab-SMU/ggtree.git)
错误: 意外的'/' in "devtools::install_git(https:/"

devtools::install_git("https://github.com/YuLab-SMU/ggtree.git")

方法二:

命令:

devtools::install_github("author/packagesname")

"author/packagesname"在url上直接复制即可
or:

library(devtools)
install_github("GuangchuangYu/yyplot")
image.png

方法三-biomanager安装ggtree(R>=3.5)-推荐

biomanager的安装见下方3.

去官网找安装代码
http://bioconductor.org/packages/release/bioc/html/ggtree.html

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install("ggtree")
image.png

wow!安装成功!并提示是否更新相关的包

image.png

3.安装biomanager (好处是每半年会对R包upgrade&debug)

Bioconductor在R3.5版本以后,终于放弃了source() 这种危险的链接方式,改为用新的安装方式BiocManager进行安装:

对于R 3.5 以下的版本,依旧需要使用BiocLite:

代码已经给好,不再需要source():

去官网https://bioconductor.org/install/上查R对应的安装命令,例如我的是R 3.6,对应bioconductor 3.10

image.png
>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 每六个月(其实是每年四月和十月)会对旗下的生物相关的R包进行更新和debug,install.packages在很多时候检测不到这些更新,导致使用者总是安装过时的版本

4.安装yyplot-重点

> 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
错误: Failed to install 'unknown package' from GitHub:
  Failed to install 'gglayer' from GitHub:
  Failed to connect to api.github.com port 443: Connection refused

报错:
错误: Failed to install 'unknown package' from GitHub: Failed to install 'gglayer' from GitHub: Failed to connect to api.github.com port 443: Connection refused

于是单独安装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) 

结果显示package ‘gglayer’ is not available (for R version 3.6.2)

R3.6不能安装gglayer?于是跑到Y叔的github上看支持的R版本,明明支持R>=3.5呀!!


image.png

于是重新用devtools安装

> devtools::install_github("GuangchuangYu/gglayer")
错误: Failed to install 'gglayer' from GitHub:
  Failed to connect to api.github.com port 443: Connection refused

网络问题?于是设置了代理

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终于安装成功!!

于是动手再重新安装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: 无法载入共享目标对象‘/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
错误: unable to load R code in package ‘yyplot’
停止执行
ERROR: lazy loading failed for package ‘yyplot’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/yyplot’
错误: Failed to install 'yyplot' from GitHub:
  (由警告转换成)installation of package ‘/var/folders/rr/3hs35sxn0lsfwvx91_w0vfhr0000gn/T//RtmpH6X08I/file173772d895fef/yyplot_0.0.8.tar.gz’ had non-zero exit status

仔细看报错的信息:

Error : .onLoad failed in loadNamespace() for 'sysfonts', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: 无法载入共享目标对

错误: unable to load R code in package ‘yyplot’
停止执行
ERROR: lazy loading failed for package ‘yyplot’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/yyplot’
错误: Failed to install 'yyplot' from GitHub:

google了Y叔的github yyplot的issue,看有没有人遇到类似的问题,结果,确实mac上有安装错误的issue
发现了类似的问题

image.png

有人提出解决方法,下载XQuartz,地址https://www.xquartz.org/
image.png

出现的问题叫:
sysfonts not loading/Image not found
解答参考https://github.com/yixuan/showtext/issues/13

并重新配置了经测试能登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)

说明:原创声明,部分观点参考https://zhuanlan.zhihu.com/p/50345757

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,542评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,596评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,021评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,682评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,792评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,985评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,107评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,845评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,299评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,612评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,747评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,441评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,072评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,828评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,069评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,545评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,658评论 2 350

推荐阅读更多精彩内容