Monocle操作笔记-1:软件安装

1. monocle 2安装

方式一:官网安装方式

官网描述的是调用bioconductor.org中的biocLite.R脚本安装biocLite命令,但是按照下边命令总是报错,无法调用biocLite

source("http://bioconductor.org/biocLite.R")
biocLite()
biocLite("monocle")

于是在biocLite.R脚本中修改了一下,如下:

## Mirrors: uncomment the following and change to your favorite CRAN mirror
## if you don't want to use the default (cran.rstudio.com).
## options("repos" = c(CRAN="https://cran.rstudio.com"))

## Mirrors: uncomment the following and change to your favorite Bioconductor
## mirror, if you don't want to use the default (bioconductor.org)
## options("BioC_mirror" = "https://bioconductor.org")

local({

    vers <- getRversion()
    biocVers <- tryCatch({
        BiocInstaller::biocVersion() # recent BiocInstaller
    }, error=function(...) {         # no / older BiocInstaller
        BioC_version_associated_with_R_version <-
            get(".BioC_version_associated_with_R_version",
                envir=asNamespace("tools"), inherits=FALSE)
        if (is.function(BioC_version_associated_with_R_version))
            BioC_version_associated_with_R_version()
        else                            # numeric_version
            BioC_version_associated_with_R_version
    })


    if (vers > "2.13" && biocVers > "2.8") {

        if (exists("biocLite", .GlobalEnv, inherits=FALSE)) {
            txt <- strwrap("There is an outdated biocLite() function in the
                global environment; run 'rm(biocLite)' and try again.")
            stop("\n", paste(txt, collapse="\n"))
        }

        if (!suppressWarnings(require("BiocInstaller", quietly=TRUE))) {
            a <- NULL
            p <- file.path(Sys.getenv("HOME"), ".R", "repositories")
            if (file.exists(p)) {
                a <- tools:::.read_repositories(p)
                if (!"BioCsoft" %in% rownames(a)) 
                    a <- NULL
            }
            if (is.null(a)) {
                p <- file.path(R.home("etc"), "repositories")
                a <- tools:::.read_repositories(p)
            }
            if (!"package:utils" %in% search()) {
                path <- "//bioconductor.org/biocLite.R"
                txt <- sprintf("use 'source(\"https:%s\")' or
                    'source(\"http:%s\")' to update 'BiocInstaller' after
                    library(\"utils\")", path, path)
                message(paste(strwrap(txt), collapse="\n  "))
            } else {
                if (vers >= "3.2.2" && vers < "3.3.0") {
                    ## transitioning to https support; check availability
                    con <- file(fl <- tempfile(), "w")
                    sink(con, type="message")
                    tryCatch({
                        xx <- close(file("https://bioconductor.org"))
                    }, error=function(e) {
                        message(conditionMessage(e))
                    })
                    sink(type="message")
                    close(con)
                    if (!length(readLines(fl)))
                        a["BioCsoft", "URL"] <-
                            sub("^http:", "https:", a["BioCsoft", "URL"])
                }
                ## add a conditional for Bioc releases occuring WITHIN
                ## a single R minor version. This is so that a user with a
                ## version of R (whose etc/repositories file references the
                ## no-longer-latest URL) and without BiocInstaller
                ## will be pointed to the most recent repository suitable
                ## for their version of R
                if (vers >= "3.5.0") {
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.7",
                      a["BioCsoft", "URL"])
                } else if (vers >= "3.4.0") {
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.6",
                      a["BioCsoft", "URL"]) 
                } else if (vers >= "3.3.0") {
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.4",
                      a["BioCsoft", "URL"]) 
                } else if (vers >= "3.2") {
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.2",
                      a["BioCsoft", "URL"])
                } else if (vers == "3.1.1") {
                    ## R-3.1.1's etc/repositories file at the time of the release 
                    ## of Bioc 3.0 pointed to the 2.14 repository, but we want 
                    ## new installations to access the 3.0 repository
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "3.0",
                      a["BioCsoft", "URL"])
                } else if (vers == "3.1.0") {
                    ## R-devel points to 2.14 repository
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.14",
                      a["BioCsoft", "URL"])
                } else if (vers >= "2.15" && vers < "2.16") {
                    a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.11",
                      a["BioCsoft", "URL"])
                    biocVers <- numeric_version("2.11")
                }
                install.packages("BiocInstaller", repos=a["BioCsoft", "URL"])
                if (!suppressWarnings(require("BiocInstaller",
                                              quietly=TRUE))) {
                    path0 <- "//bioconductor.org/packages"
                    path <- sprintf("%s/%s/bioc", path0, as.character(biocVers))
                    txt0 <- "'biocLite.R' failed to install 'BiocInstaller',
                        use 'install.packages(\"BiocInstaller\",
                        repos=\"https:%s\")' or
                        'install.packages(\"BiocInstaller\", repos=\"http:%s\")'"
                    txt <- sprintf(txt0, path, path)
                    message(paste(strwrap(txt), collapse="\n  "))
                }
            }
        } else {
             ## BiocInstaller version 1.16.0-1.18.1 do not
             ## automatically update when type=="source"; notify users
             ## when they have updated R over their old libraries
             installerVersion <- utils::packageVersion("BiocInstaller")
             test0 <- (vers > "3.1.2") &&
                 !identical(getOption("pkgType"), "source") &&
                     (installerVersion >= "1.16.0") &&
                         (installerVersion <= "1.16.4")
             if (test0) {
                 if (installerVersion < "1.16.4") {
                     txt <- "Update BiocInstaller with
                         oldPkgType=options(pkgType=\"source\");
                         biocLite(\"BiocInstaller\"); options(oldPkgType)"
                     message(paste(strwrap(txt, exdent=2), collapse="\n"))
                 }
                 if (vers >= "3.2") {
                     path <- "//bioconductor.org/biocLite.R"
                     txt <- sprintf("BiocInstaller version %s is too old for
                         R version %s; remove.packages(\"BiocInstaller\"),
                         re-start R, then source(\"https:%s\") or
                         source(\"http:%s\")", biocVers, vers, path, path)
                     warning(paste(strwrap(txt, exdent=2), collapse="\n"))
                 }
             }
         }
    } else {
        tryCatch({
            source("https://bioconductor.org/getBioC.R")
        }, error=function(e) {
            warning("https: failed (", conditionMessage(e), "), trying http",
                    immediate.=TRUE)
            source("http://bioconductor.org/getBioC.R")
        })
        biocLite <<-
            function(pkgs, groupName="lite", ...)
            {
                if (missing(pkgs))
                    biocinstall(groupName=groupName, ...)
                else
                    biocinstall(pkgs=pkgs, groupName=groupName, ...)
            }
    }
})

先在R中运行上边脚本,但前提是安装了最新的R(>2.13)和BiocInstaller(> 2.8)

> BiocInstaller::biocVersion()
[1] ‘3.7’
> getRversion()
[1] ‘4.1.0’

方式二:Bioconductor安装方式(简单,直接,方便)

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

BiocManager::install("monocle")

安装monocle依赖包

library(monocle)
install.packages("devtools")
devtools::install_github("cole-trapnell-lab/monocle-release@develop")

2. monocle3安装

先安装依赖包,可能会出现由于biocViews,RBGL(依赖包的依赖包)版本过低发生的报错,但并不是什么大问题,安装最新的版本即可

BiocManager::install(c('BiocGenerics', 'DelayedArray', 'DelayedMatrixStats',
                       'limma', 'S4Vectors', 'SingleCellExperiment',
                       'SummarizedExperiment', 'batchelor', 'Matrix.utils'))

安装monocle3

install.packages("devtools")
devtools::install_github('cole-trapnell-lab/leidenbase')
devtools::install_github('cole-trapnell-lab/monocle3')
devtools::install_github('cole-trapnell-lab/monocle3', ref="develop")
library(monocle3)
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装monocle2,您可以按照以下步骤进行操作: 1. 首先,检查一下可用的monocle版本,可以使用以下命令:conda search monocle 2. 创建一个新的conda环境,可以使用以下命令:conda create -n monocle2 3. 激活monocle2环境,可以使用以下命令:conda activate monocle2 4. 安装monocle 2.18.0版本,可以使用以下命令:conda install bioconductor-monocle==2.18.0 5. 在R中加载monocle库,可以使用以下命令:library(monocle,lib.loc="刚刚创建的monocle2环境所在路径/lib/R/library") 如果您之前没有创建conda环境,可以按照上述步骤创建一个新的环境并安装monocle2。\[1\] 希望这可以帮助您安装monocle2!如果您有任何其他问题,请随时提问。 #### 引用[.reference_title] - *1* *2* [linux安装轨迹分析所需Rmonocle2和monocle3的方法](https://blog.csdn.net/x_yAOTU/article/details/126071592)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Monocle操作笔记-1:软件安装](https://blog.csdn.net/flashan_shensanceng/article/details/121402718)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值