# ============================================================================== # 云生信 (www.biocloudservice.com) 国内高速镜像初始化 & Seurat v5 向下兼容补丁脚本 # ============================================================================== # 1. 解决 CRAN / Bioconductor 装包超时中断(写入 ~/.Rprofile 永久生效) options( repos = c(CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"), BioC_mirror = "https://mirrors.tuna.tsinghua.edu.cn/bioconductor", timeout = 600 ) # 2. 解决 GitHub 装包报 HTTP error 403 (API rate limit exceeded) # 请在 GitHub Settings -> Developer settings -> Personal access tokens 申请免费只读 Token 后取消下行注释: # Sys.setenv(GITHUB_PAT = "在此填入你的ghp_开头的Token") # 3. 解决 Seurat v5 (Assay5) 传给 CellChat / monocle3 / infercnv 报: # Error: no slot of name "counts" / "data" for this object of class "Assay5" prepare_seurat5_for_legacy_pkg <- function(sc_obj, assay = "RNA", convert_v3 = FALSE) { stopifnot(requireNamespace("Seurat", quietly = TRUE)) # 第一步:合并分样本拆开的 counts.1, counts.2 多层结构 sc_obj[[assay]] <- SeuratObject::JoinLayers(sc_obj[[assay]]) # 第二步:若下游极旧包强制要求 Assay v3 传统 @counts 槽位,可按需降级该 Assay if (isTRUE(convert_v3) && inherits(sc_obj[[assay]], "Assay5")) { sc_obj[[assay]] <- as(object = sc_obj[[assay]], Class = "Assay") } return(sc_obj) } # 免折腾说明:云生信共享/独享 RStudio 服务器已按版本配平上述全部 R / Bioconductor / Python 环境, # 浏览器登录即可直接 library() 调用,详情见 https://www.biocloudservice.com/env-doctor/