GNU Manuals Online中各种软件的摘要介绍

博客介绍了多个GNU构建工具及命令行程序。如acct提供系统使用信息,autoconf可自动设置软件源代码包以适应多种系统,automake用于简化生成makefile.in的操作,还列举了bash、gcc等众多工具和程序。
GNU Manuals Online
         http://www.gnu.org/manual/manual.html

Available Manuals:

  • acct          

全称帐户工具(accouting utilities )   用来提供系统管理员系统使用上的信息,包括连接,执行的程序,和系统资源的使用状况。——有几个命令行程序组成:ac,accton,last,lastcomm,sa,dump-acct,dump-utmp,通过命令行参数提供更多功能。                

autoconf提供了一种命令行脚(shell scripts )本来自动设置软件源代码包,以适应多种unix-like系统的需要。——由autoconf生成的设置脚本在运行的时候不依靠于autoconf,即可在无此程序的系统上安装。其生成的脚本会自动测试所调用的属性在所运行系统上的效果,以做到对哪怕经过个性化设置的无人值守运行。其支持脚本复用和统一更新。他能够更方便的支持大规模代码的设置,在进行特殊设置的时候,还支持cross-compiling。它是GNU build tools(包括Autoconf, Automake, and Libtool)的一部分。Autoconf solves an important problem--reliable discovery of system-specific build and run-time information.Autoconf生成的设置脚本通常称为configure。Autoconf需要M4以生成命令行脚本。

(GNU网页出现错误)

用于生成makefile.in的简化操作。其通过在中间文件makefile.am中使用更为简单的语法,生成兼容GNU makefile标准的makefile.ins文件,去除了编写makefile.ins的繁复劳动。makefile.am文件有一系列make可变定义(make variable definitions——在make文档中也称作make macros )和少量make规则(rules),每个.am文件会生成一个.in文件,每个工程的目录下只需要一个makefile.am文件。Automake要求和Autoconf一起使用,他支持configure.in和configure.ac文件,同时对configure文件的内容有严格限制。Automake也支持同Texinfo一起使用生成文档,同时也对Emacs Lisp 、Gettext、Libtool、Java、Python有一定支持。Automake在生成.in文件的时候需要perl的支持。

 

参考的代码: # Check presence of rows with cell_id of 0 cells_0 <- grep("_0$", rownames(exprMat), value = TRUE) # Check presence of Negative and SystemControl probes columns negPrb_col <- grep("^Neg", colnames(exprMat), value = TRUE) # Neg columns sysCon_col <- grep("^SystemControl", colnames(exprMat), value = TRUE) # SystemControl columns # Show head expression matrix as.matrix(exprMat[1:6, 1:10]) Chrna4 Slc6a1 Cd109 Ldha Aldoc Drd1 Tank Rit2 Prkag2 Lpar3 c_1_1_0 9 58 11 30 938 6 28 20 15 2 c_1_1_1 0 0 0 0 0 0 0 0 0 0 c_1_1_2 0 0 0 0 0 0 0 0 1 0 c_1_1_3 5 1 0 1 2 0 0 0 0 0 c_1_1_4 1 1 0 1 0 0 0 2 1 0 c_1_1_5 0 0 0 2 2 0 0 0 0 0 但是我用exprMat <- read.csv("Run5961_PDAC_Slide1_exprMat_file.csv", header = TRUE) 得到的结果与参考代码不同 R version 4.4.3 (2025-02-28) -- "Trophy Case" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R是自由软件,不附带任何担保。 在某些条件下你可以将其自由分发。 用'license()'或'licence()'来看分发的详细条件。 R是个合作计划,有许多人为之做出了贡献. 用'contributors()'来看合著者的详细情况 用'citation()'会告诉你如何在出版物中正确地引用R或R程序包。 用'demo()'来看一些示例程序,用'help()'来阅读在线帮助文件,或 用'help.start()'通过HTML浏览器来看帮助文件。 输入'q()'退出R. > setwd("/data1/firefox") > BiocManager::install("NanoStringNCTtools") 'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details. Replacement repositories: CRAN: https://cloud.r-project.org Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.3 (2025-02-28) Installing package(s) 'NanoStringNCTtools' Installation paths not writeable, unable to update packages path: /usr/lib/R/library packages: boot, codetools, foreign, lattice, Matrix, mgcv, nlme, spatial Old packages: 'aplot', 'BiocManager', 'BiocParallel', 'bookdown', 'broom', 'Cairo', 'checkmate', 'cli', 'collections', 'colorspace', 'cols4all', 'commonmark', 'cowplot', 'credentials', 'crosstalk', 'curl', 'data.table', 'data.tree', 'dbplyr', 'dbscan', 'Deriv', 'diffobj', 'doBy', 'DT', 'dtplyr', 'evaluate', 'fastcluster', 'fields', 'fitdistrplus', 'forcats', 'fs', 'future', 'future.apply', 'gargle', 'generics', 'ggforce', 'ggfun', 'ggnetwork', 'ggnewscale', 'ggplot2', 'ggplotify', 'ggpubr', 'ggraph', 'ggridges', 'ggsci', 'ggtangle', 'gh', 'globals', 'googledrive', 'googlesheets4', 'haven', 'here', 'httpuv', 'httr2', 'igraph', 'later', 'logger', 'magick', 'magrittr', 'maps', 'miniUI', 'mockr', 'modeltools', 'msigdbr', 'nanoarrow', 'openssl', 'parallelly', 'patchwork', 'pbapply', 'pbkrtest', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'pkgload', 'plotly', 'progressr', 'promises', 'ps', 'psych', 'purrr', 'R.cache', 'R.oo', 'ragg', 'Rcpp', 'RcppArmadillo', 'RcppParallel', 'reformulas', 'ResidualMatrix', 'restfulr', 'reticulate', 'rlang', 'roxygen2', 'rprojroot', 'rsample', 'RSQLite', 'RUnit', 'rvest', 's2', 'sass', 'scales', 'scatterpie', 'SCpubr', 'sctransform', 'SeuratObject', 'sf', 'shiny', 'spacesXYZ', 'spatstat', 'spatstat.data', 'spatstat.explore', 'spatstat.geom', 'spatstat.linnet', 'spatstat.model', 'spatstat.random', 'spatstat.univar', 'spatstat.utils', 'spdep', 'stringr', 'survminer', 'svglite', 'systemfonts', 'tensor', 'terra', 'textshaping', 'TH.data', 'tibble', 'tinytex', 'usethis', 'utf8', 'V8', 'vroom', 'waldo', 'xfun', 'xgboost', 'XML', 'xml2', 'yulab.utils', 'zip', 'zoo' Update all/some/none? [a/s/n]: n 警告信息: package ‘NanoStringNCTtools’ is not available for Bioconductor version '3.20' A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages > BiocManager::install("NanoStringNCTools") 'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details. Replacement repositories: CRAN: https://cloud.r-project.org Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.3 (2025-02-28) Installing package(s) 'NanoStringNCTools' 还安装依赖关系‘S7’, ‘scales’, ‘ggplot2’, ‘ggiraph’, ‘ggthemes’ 试开URL’https://cloud.r-project.org/src/contrib/S7_0.2.0.tar.gz' Content type 'application/x-gzip' length 183153 bytes (178 KB) ================================================== downloaded 178 KB 试开URL’https://cloud.r-project.org/src/contrib/scales_1.4.0.tar.gz' Content type 'application/x-gzip' length 328671 bytes (320 KB) ================================================== downloaded 320 KB 试开URL’https://cloud.r-project.org/src/contrib/ggplot2_4.0.0.tar.gz' Content type 'application/x-gzip' length 3810397 bytes (3.6 MB) ================================================== downloaded 3.6 MB 试开URL’https://cloud.r-project.org/src/contrib/ggiraph_0.9.1.tar.gz' Content type 'application/x-gzip' length 392782 bytes (383 KB) ================================================== downloaded 383 KB 试开URL’https://cloud.r-project.org/src/contrib/ggthemes_5.1.0.tar.gz' Content type 'application/x-gzip' length 493992 bytes (482 KB) ================================================== downloaded 482 KB 试开URL’https://bioconductor.org/packages/3.20/bioc/src/contrib/NanoStringNCTools_1.14.0.tar.gz' Content type 'application/gzip' length 382477 bytes (373 KB) ================================================== downloaded 373 KB * installing *source* package ‘S7’ ... ** 成功将‘S7’程序包解包并MD5和检查 ** using staged installation ** libs using C compiler: ‘gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0’ gcc -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init.c -o init.o gcc -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c method-dispatch.c -o method-dispatch.o gcc -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c prop.c -o prop.o gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o S7.so init.o method-dispatch.o prop.o -L/usr/lib/R/lib -lR installing to /home/user/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-S7/00new/S7/libs ** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** checking absolute paths in shared objects and dynamic libraries ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (S7) * installing *source* package ‘scales’ ... ** 成功将‘scales’程序包解包并MD5和检查 ** using staged installation ** R ** byte-compile and prepare package for lazy loading ** help *** installing help indices *** copying figures ** 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 (scales) * installing *source* package ‘ggplot2’ ... ** 成功将‘ggplot2’程序包解包并MD5和检查 ** using staged installation ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices *** copying figures ** building package indices ** installing vignettes ** 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 (ggplot2) * installing *source* package ‘ggiraph’ ... ** 成功将‘ggiraph’程序包解包并MD5和检查 ** using staged installation ** libs using C++ compiler: ‘g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0’ g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c RcppExports.cpp -o RcppExports.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c a_color.cpp -o a_color.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c clip.cpp -o clip.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c dsvg.cpp -o dsvg.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c dsvg_dev.cpp -o dsvg_dev.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c geom.cpp -o geom.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c indexed.cpp -o indexed.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c interactive.cpp -o interactive.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c mask.cpp -o mask.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c pattern.cpp -o pattern.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c raster.cpp -o raster.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c shapes.cpp -o shapes.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c svg.cpp -o svg.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c text.cpp -o text.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c tinyxml2.cpp -o tinyxml2.o g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I'/home/user/R/x86_64-pc-linux-gnu-library/4.4/systemfonts/include' -fpic -g -O2 -fdebug-prefix-map=/build/r-base-0GHeEU/r-base-4.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c utils.cpp -o utils.o g++ -std=gnu++17 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o ggiraph.so RcppExports.o a_color.o clip.o dsvg.o dsvg_dev.o geom.o indexed.o interactive.o mask.o pattern.o raster.o shapes.o svg.o text.o tinyxml2.o utils.o -lpng -lz -L/usr/lib/R/lib -lR installing to /home/user/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-ggiraph/00new/ggiraph/libs ** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices *** copying figures ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** checking absolute paths in shared objects and dynamic libraries ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (ggiraph) * installing *source* package ‘ggthemes’ ... ** 成功将‘ggthemes’程序包解包并MD5和检查 ** using staged installation ** R ** data *** moving datasets to lazyload DB ** inst ** 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 (ggthemes) * installing *source* package ‘NanoStringNCTools’ ... ** 成功将‘NanoStringNCTools’程序包解包并MD5和检查 ** using staged installation ** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** 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 (NanoStringNCTools) 下载的程序包在 ‘/tmp/Rtmp5RH1TC/downloaded_packages’里 Installation paths not writeable, unable to update packages path: /usr/lib/R/library packages: boot, codetools, foreign, lattice, Matrix, mgcv, nlme, spatial Old packages: 'aplot', 'BiocManager', 'BiocParallel', 'bookdown', 'broom', 'Cairo', 'checkmate', 'cli', 'collections', 'colorspace', 'cols4all', 'commonmark', 'cowplot', 'credentials', 'crosstalk', 'curl', 'data.table', 'data.tree', 'dbplyr', 'dbscan', 'Deriv', 'diffobj', 'doBy', 'DT', 'dtplyr', 'evaluate', 'fastcluster', 'fields', 'fitdistrplus', 'forcats', 'fs', 'future', 'future.apply', 'gargle', 'generics', 'ggforce', 'ggfun', 'ggnetwork', 'ggnewscale', 'ggplotify', 'ggpubr', 'ggraph', 'ggridges', 'ggsci', 'ggtangle', 'gh', 'globals', 'googledrive', 'googlesheets4', 'haven', 'here', 'httpuv', 'httr2', 'igraph', 'later', 'logger', 'magick', 'magrittr', 'maps', 'miniUI', 'mockr', 'modeltools', 'msigdbr', 'nanoarrow', 'openssl', 'parallelly', 'patchwork', 'pbapply', 'pbkrtest', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'pkgload', 'plotly', 'progressr', 'promises', 'ps', 'psych', 'purrr', 'R.cache', 'R.oo', 'ragg', 'Rcpp', 'RcppArmadillo', 'RcppParallel', 'reformulas', 'ResidualMatrix', 'restfulr', 'reticulate', 'rlang', 'roxygen2', 'rprojroot', 'rsample', 'RSQLite', 'RUnit', 'rvest', 's2', 'sass', 'scatterpie', 'SCpubr', 'sctransform', 'SeuratObject', 'sf', 'shiny', 'spacesXYZ', 'spatstat', 'spatstat.data', 'spatstat.explore', 'spatstat.geom', 'spatstat.linnet', 'spatstat.model', 'spatstat.random', 'spatstat.univar', 'spatstat.utils', 'spdep', 'stringr', 'survminer', 'svglite', 'systemfonts', 'tensor', 'terra', 'textshaping', 'TH.data', 'tibble', 'tinytex', 'usethis', 'utf8', 'V8', 'vroom', 'waldo', 'xfun', 'xgboost', 'XML', 'xml2', 'yulab.utils', 'zip', 'zoo' Update all/some/none? [a/s/n]: n > library(NanoStringNCTools) 载入需要的程序包:Biobase 载入需要的程序包:BiocGenerics 载入程序包:‘BiocGenerics’ The following objects are masked from ‘package:stats’: IQR, mad, sd, var, xtabs The following objects are masked from ‘package:base’: anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce, rownames, sapply, saveRDS, setdiff, table, tapply, union, unique, unsplit, which.max, which.min Welcome to Bioconductor Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see 'citation("Biobase")', and for packages 'citation("pkgname")'. 载入需要的程序包:S4Vectors 载入需要的程序包:stats4 载入程序包:‘S4Vectors’ The following object is masked from ‘package:utils’: findMatches The following objects are masked from ‘package:base’: expand.grid, I, unname 载入需要的程序包:ggplot2 > library(Seurat) 载入需要的程序包:SeuratObject 载入需要的程序包:sp 载入程序包:‘SeuratObject’ The following object is masked from ‘package:S4Vectors’: intersect The following object is masked from ‘package:BiocGenerics’: intersect The following objects are masked from ‘package:base’: intersect, t > slide1_obj <- ReadNanostring( + data.dir = ".", + mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", + metadata.file = "GSE277782_Run5961_PDAC_Slide1_metadata_file.csv.gz", + segmentations.file = "GSE277782_Run5961_PDAC_Slide1-polygons.csv.gz", + fov.file = "GSE277782_Run5961_PDAC_Slide1_fov_positions_file.csv.gz", + assay = "Spatial" + ) 错误于ReadNanostring(data.dir = ".", mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", : 参数没有用(fov.file = "GSE277782_Run5961_PDAC_Slide1_fov_positions_file.csv.gz", assay = "Spatial") > slide1_obj <- ReadNanostring( + data.dir = ".", + mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", + metadata.file = "GSE277782_Run5961_PDAC_Slide1_metadata_file.csv.gz", + segmentations.file = "GSE277782_Run5961_PDAC_Slide1-polygons.csv.gz" + ) 错误于ReadNanostring(data.dir = ".", mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", : 找不到对象'mx' > slide1_obj <- ReadNanostring( + data.dir = "/data1/firefox", + mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", + metadata.file = "GSE277782_Run5961_PDAC_Slide1_metadata_file.csv.gz", + segmentations.file = "GSE277782_Run5961_PDAC_Slide1-polygons.csv.gz" + ) 错误于ReadNanostring(data.dir = "/data1/firefox", mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", : 找不到对象'mx' > required_files <- c( + mtx = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", + metadata = "GSE277782_Run5961_PDAC_Slide1_metadata_file.csv.gz", + segmentations = "GSE277782_Run5961_PDAC_Slide1-polygons.csv.gz" + ) > file_check <- sapply(required_files, function(file) { + file.exists(file) + }) > if (all(file_check)) { + cat("✅ 所有必要文件均存在\n") + } else { + missing_files <- names(file_check)[!file_check] + cat("❌ 缺失以下必要文件:\n") + cat(paste("-", missing_files, "\n", sep="")) + stop("请先确保所有文件存在于指定目录") + } ✅ 所有必要文件均存在 > # 检查表达矩阵格式(前5行5列) > cat("\n=== 验证表达矩阵格式 ===\n") === 验证表达矩阵格式 === > tryCatch({ + mtx_sample <- read.csv(required_files["mtx"], nrows=5, header=TRUE) + cat("表达矩阵前5行5列预览:\n") + print(head(mtx_sample[, 1:5])) + if (!is.numeric(as.matrix(mtx_sample[, -1]))) { + stop("表达矩阵包含非数值数据") + } + cat("✅ 表达矩阵格式验证通过\n") + }, error = function(e) { + cat("❌ 表达矩阵格式错误:", e$message, "\n") + stop("请检查表达矩阵文件格式") + }) 表达矩阵前5行5列预览: fov cell_ID RAMP2 CD83 RYK 1 1 0 13 59 36 2 1 1 0 0 1 3 1 2 0 0 0 4 1 3 1 0 0 5 1 4 0 0 0 ✅ 表达矩阵格式验证通过 > # ----------------------------- > # 步骤2:使用修正参数调用ReadNanostring > # ----------------------------- > cat("\n=== 尝试加载数据 ===\n") === 尝试加载数据 === > if (!requireNamespace("NanoStringNCTools", quietly=TRUE)) { + stop("NanoStringNCTools包未安装") + } > library(NanoStringNCTools) > library(Seurat) > # 尝试使用基础参数加载(避免可能的内部变量冲突) > tryCatch({ + # 仅使用必要参数,避免复杂参数组合 + slide1_obj <- ReadNanostring( + data.dir = data_dir, + mtx.file = required_files["mtx"], + metadata.file = required_files["metadata"], + segmentations.file = required_files["segmentations"], + verbose = TRUE # 输出详细过程信息 + ) + cat("✅ 数据加载成功\n") + }, error = function(e) { + cat("❌ ReadNanostring调用失败:", e$message, "\n") + + # ----------------------------- + # 备选方案:手动构建Seurat对象 + # ----------------------------- + cat("\n=== 尝试备选方案:手动构建Seurat对象 ===\n") + + # 1. 读取表达矩阵 + cat("读取表达矩阵...\n") + expr_matrix <- read.csv(required_files["mtx"], row.names=1) %>% as.matrix() + + # 2. 读取元数据 + cat("读取元数据...\n") + metadata <- read.csv(required_files["metadata"], row.names=1) + + # 3. 读取空间坐标(从segmentations文件) + cat("读取空间坐标...\n") + segmentations <- read.csv(required_files["segmentations"]) + coords <- segmentations %>% + select(cell_id, x, y) %>% # 根据实际列名调整 + column_to_rownames("cell_id") + + # 4. 创建Seurat对象 + cat("创建Seurat对象...\n") + seurat_obj <- CreateSeuratObject( + counts = expr_matrix, + meta.data = metadata + ) + + # 5. 添加空间坐标 + if (nrow(coords) > 0) { + seurat_obj@images$image <- new( + Class = "SpatialImage", + assay = "RNA", + coordinates = coords[colnames(seurat_obj), ] + ) + cat("✅ 已添加空间坐标信息\n") + } + + # 6. 保存结果 + saveRDS(seurat_obj, "manual_seurat_object.rds") + cat("✅ 备选方案成功:手动创建的Seurat对象已保存为manual_seurat_object.rds\n") + cat("请使用以下代码加载:\n") + cat("seurat_obj <- readRDS('manual_seurat_object.rds')\n") + }) ❌ ReadNanostring调用失败: 参数没有用(verbose = TRUE) === 尝试备选方案:手动构建Seurat对象 === 读取表达矩阵... 错误于read.csv(required_files["mtx"], row.names = 1) %>% as.matrix(): 没有"%>%"这个函数 Called from: value[[3L]](cond) Browse[1]> Q > library(dplyr) 载入程序包:‘dplyr’ The following object is masked from ‘package:NanoStringNCTools’: groups The following objects are masked from ‘package:S4Vectors’: first, intersect, rename, setdiff, setequal, union The following object is masked from ‘package:Biobase’: combine The following objects are masked from ‘package:BiocGenerics’: combine, intersect, setdiff, union The following objects are masked from ‘package:stats’: filter, lag The following objects are masked from ‘package:base’: intersect, setdiff, setequal, union > # 尝试使用基础参数加载(避免可能的内部变量冲突) > tryCatch({ + # 仅使用必要参数,避免复杂参数组合 + slide1_obj <- ReadNanostring( + data.dir = data_dir, + mtx.file = required_files["mtx"], + metadata.file = required_files["metadata"], + segmentations.file = required_files["segmentations"], + verbose = TRUE # 输出详细过程信息 + ) + cat("✅ 数据加载成功\n") + }, error = function(e) { + cat("❌ ReadNanostring调用失败:", e$message, "\n") + + # ----------------------------- + # 备选方案:手动构建Seurat对象 + # ----------------------------- + cat("\n=== 尝试备选方案:手动构建Seurat对象 ===\n") + + # 1. 读取表达矩阵 + cat("读取表达矩阵...\n") + expr_matrix <- read.csv(required_files["mtx"], row.names=1) %>% as.matrix() + + # 2. 读取元数据 + cat("读取元数据...\n") + metadata <- read.csv(required_files["metadata"], row.names=1) + + # 3. 读取空间坐标(从segmentations文件) + cat("读取空间坐标...\n") + segmentations <- read.csv(required_files["segmentations"]) + coords <- segmentations %>% + select(cell_id, x, y) %>% # 根据实际列名调整 + column_to_rownames("cell_id") + + # 4. 创建Seurat对象 + cat("创建Seurat对象...\n") + seurat_obj <- CreateSeuratObject( + counts = expr_matrix, + meta.data = metadata + ) + + # 5. 添加空间坐标 + if (nrow(coords) > 0) { + seurat_obj@images$image <- new( + Class = "SpatialImage", + assay = "RNA", + coordinates = coords[colnames(seurat_obj), ] + ) + cat("✅ 已添加空间坐标信息\n") + } + + # 6. 保存结果 + saveRDS(seurat_obj, "manual_seurat_object.rds") + cat("✅ 备选方案成功:手动创建的Seurat对象已保存为manual_seurat_object.rds\n") + cat("请使用以下代码加载:\n") + cat("seurat_obj <- readRDS('manual_seurat_object.rds')\n") + }) ❌ ReadNanostring调用失败: 参数没有用(verbose = TRUE) === 尝试备选方案:手动构建Seurat对象 === 读取表达矩阵... 错误于h(simpleError(msg, call)): 在为函数“as.matrix”选择方法时计算参数“x”时出错:'row.names'里不能有重复的名称 Called from: h(simpleError(msg, call)) Browse[1]> Q > ?ReadNanostring > slide1_obj <- ReadNanostring( + data.dir = "/data1/firefox", + mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", + metadata.file = "GSE277782_Run5961_PDAC_Slide1_metadata_file.csv.gz", + molecules.file = "" + segmentations.file = "GSE277782_Run5961_PDAC_Slide1-polygons.csv.gz" 错误: 意外的符号 于 " molecules.file = "" segmentations.file" > slide1_obj <- ReadNanostring( + data.dir = "/data1/firefox", + mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", + metadata.file = "GSE277782_Run5961_PDAC_Slide1_metadata_file.csv.gz", + segmentations.file = "GSE277782_Run5961_PDAC_Slide1-polygons.csv.gz" + ) 错误于ReadNanostring(data.dir = "/data1/firefox", mtx.file = "GSE277782_Run5961_PDAC_Slide1_exprMat_file.csv.gz", : 找不到对象'mx' > rm(mtx_sample) > setwd("/data1/firefox/GSE277782_Run5961_PDAC_Slide1") > slide1_obj <- ReadNanostring( + data.dir = "/data1/firefox/GSE277782_Run5961_PDAC_Slide1", + mtx.file = "Run5961_PDAC_Slide1_exprMat_file.csv", + metadata.file = "Run5961_PDAC_Slide1_metadata_file.csv", + molecules.file = "Run5961_PDAC_Slide1_tx_file.csv", + segmentations.file = "Run5961_PDAC_Slide1-polygons.csv" + ) > View(slide1_obj) > library(magick) Linking to ImageMagick 6.9.10.23 Enabled features: fontconfig, freetype, fftw, lcms, pango, webp, x11 Disabled features: cairo, ghostscript, heic, raw, rsvg Using 96 threads > slide1_obj <- ReadNanostring( + data.dir = "/data1/firefox/GSE277782_Run5961_PDAC_Slide1", + mtx.file = "Run5961_PDAC_Slide1_exprMat_file.csv", + metadata.file = "Run5961_PDAC_Slide1_metadata_file.csv", + molecules.file = "Run5961_PDAC_Slide1_tx_file.csv", + segmentations.file = "Run5961_PDAC_Slide1-polygons.csv" + ) > fov_positions <- read.csv( + "Run5961_PDAC_Slide1_fov_positions_file.csv", + header = TRUE + ) > cat("FOV位置数据列名:", colnames(fov_positions), "\n") FOV位置数据列名: fov x_global_px y_global_px > max_x <- max(fov_positions$x_global_px) + 2048 > max_x <- max(fov_positions$x_global_px) + 2048 > max_y <- max(fov_positions$y_global_px) + 2048 # 假设单视野高2048像素 > combined_image <- image_blank( + width = max_x, + height = max_y, + color = "white" # 白色背景 + ) 错误: rsession: width or height exceeds limit `#FFFFFFFFFFFF' @ error/cache.c/OpenPixelCache/3911 > cat("x_global_px范围:", range(fov_positions$x_global_px), "\n") x_global_px范围: -193718.9 -96445.92 > > cat("y_global_px范围:", range(fov_positions$y_global_px), "\n") y_global_px范围: -74903.74 65186.42 > > View(fov_positions) > library(data.table) # Efficient data management data.table 1.17.0,使用了 48 个线程(参见 ?getDTthreads)。 最新的消息:r-datatable.com ********** Running data.table in English; package support is available in English only. When searching for online help, be sure to also check for the English error message. This can be obtained by looking at the po/R-<locale>.po and po/<locale>.po files in the package source, where the native language and English error messages can be found side-by-side. You can also try calling Sys.setLanguage('en') prior to reproducing the error message. ********** 载入程序包:‘data.table’ The following objects are masked from ‘package:dplyr’: between, first, last The following objects are masked from ‘package:S4Vectors’: first, second > library(Matrix) # Sparse matrices 载入程序包:‘Matrix’ The following object is masked from ‘package:S4Vectors’: expand > library(here) # Enhanced file referencing in project-oriented workflows here() starts at /data1/firefox/GSE277782_Run5961_PDAC_Slide1 > library(vecsets) # Enhanced version of the Set Operations from "base" 错误于library(vecsets): 不存在叫‘vecsets’这个名称的程序包 > BiocManager::install("vecsets") 'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details. Replacement repositories: CRAN: https://cloud.r-project.org Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.3 (2025-02-28) Installing package(s) 'vecsets' 还安装依赖关系‘pracma’ 试开URL’https://cloud.r-project.org/src/contrib/pracma_2.4.4.tar.gz' Content type 'application/x-gzip' length 397815 bytes (388 KB) ================================================== downloaded 388 KB 试开URL’https://cloud.r-project.org/src/contrib/vecsets_1.4.tar.gz' Content type 'application/x-gzip' length 5714 bytes ================================================== downloaded 5714 bytes * installing *source* package ‘pracma’ ... ** 成功将‘pracma’程序包解包并MD5和检查 ** using staged installation ** R ** data *** moving datasets to lazyload DB ** demo ** 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 (pracma) * installing *source* package ‘vecsets’ ... ** 成功将‘vecsets’程序包解包并MD5和检查 ** 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 (vecsets) 下载的程序包在 ‘/tmp/Rtmp5RH1TC/downloaded_packages’里 Installation paths not writeable, unable to update packages path: /usr/lib/R/library packages: boot, codetools, foreign, lattice, Matrix, mgcv, nlme, spatial Old packages: 'aplot', 'BiocManager', 'BiocParallel', 'bookdown', 'broom', 'Cairo', 'checkmate', 'cli', 'collections', 'colorspace', 'cols4all', 'commonmark', 'cowplot', 'credentials', 'crosstalk', 'curl', 'data.table', 'data.tree', 'dbplyr', 'dbscan', 'Deriv', 'diffobj', 'doBy', 'DT', 'dtplyr', 'evaluate', 'fastcluster', 'fields', 'fitdistrplus', 'forcats', 'fs', 'future', 'future.apply', 'gargle', 'generics', 'ggforce', 'ggfun', 'ggnetwork', 'ggnewscale', 'ggplotify', 'ggpubr', 'ggraph', 'ggridges', 'ggsci', 'ggtangle', 'gh', 'globals', 'googledrive', 'googlesheets4', 'haven', 'here', 'httpuv', 'httr2', 'igraph', 'later', 'logger', 'magick', 'magrittr', 'maps', 'miniUI', 'mockr', 'modeltools', 'msigdbr', 'nanoarrow', 'openssl', 'parallelly', 'patchwork', 'pbapply', 'pbkrtest', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'pkgload', 'plotly', 'progressr', 'promises', 'ps', 'psych', 'purrr', 'R.cache', 'R.oo', 'ragg', 'Rcpp', 'RcppArmadillo', 'RcppParallel', 'reformulas', 'ResidualMatrix', 'restfulr', 'reticulate', 'rlang', 'roxygen2', 'rprojroot', 'rsample', 'RSQLite', 'RUnit', 'rvest', 's2', 'sass', 'scatterpie', 'SCpubr', 'sctransform', 'SeuratObject', 'sf', 'shiny', 'spacesXYZ', 'spatstat', 'spatstat.data', 'spatstat.explore', 'spatstat.geom', 'spatstat.linnet', 'spatstat.model', 'spatstat.random', 'spatstat.univar', 'spatstat.utils', 'spdep', 'stringr', 'survminer', 'svglite', 'systemfonts', 'tensor', 'terra', 'textshaping', 'TH.data', 'tibble', 'tinytex', 'usethis', 'utf8', 'V8', 'vroom', 'waldo', 'xfun', 'xgboost', 'XML', 'xml2', 'yulab.utils', 'zip', 'zoo' Update all/some/none? [a/s/n]: n > library(vecsets) # Enhanced version of the Set Operations from "base" > library(dplyr) # For the use of pipes %>% > library(kableExtra) # For table formatting 错误于library(kableExtra): 不存在叫‘kableExtra’这个名称的程序包 > BiocManager::install("kableExtra") 'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package = "BiocManager")' for details. Replacement repositories: CRAN: https://cloud.r-project.org Bioconductor version 3.20 (BiocManager 1.30.25), R 4.4.3 (2025-02-28) Installing package(s) 'kableExtra' 试开URL’https://cloud.r-project.org/src/contrib/kableExtra_1.4.0.tar.gz' Content type 'application/x-gzip' length 1824636 bytes (1.7 MB) ================================================== downloaded 1.7 MB * installing *source* package ‘kableExtra’ ... ** 成功将‘kableExtra’程序包解包并MD5和检查 ** using staged installation ** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** 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 (kableExtra) 下载的程序包在 ‘/tmp/Rtmp5RH1TC/downloaded_packages’里 Installation paths not writeable, unable to update packages path: /usr/lib/R/library packages: boot, codetools, foreign, lattice, Matrix, mgcv, nlme, spatial Old packages: 'aplot', 'BiocManager', 'BiocParallel', 'bookdown', 'broom', 'Cairo', 'checkmate', 'cli', 'collections', 'colorspace', 'cols4all', 'commonmark', 'cowplot', 'credentials', 'crosstalk', 'curl', 'data.table', 'data.tree', 'dbplyr', 'dbscan', 'Deriv', 'diffobj', 'doBy', 'DT', 'dtplyr', 'evaluate', 'fastcluster', 'fields', 'fitdistrplus', 'forcats', 'fs', 'future', 'future.apply', 'gargle', 'generics', 'ggforce', 'ggfun', 'ggnetwork', 'ggnewscale', 'ggplotify', 'ggpubr', 'ggraph', 'ggridges', 'ggsci', 'ggtangle', 'gh', 'globals', 'googledrive', 'googlesheets4', 'haven', 'here', 'httpuv', 'httr2', 'igraph', 'later', 'logger', 'magick', 'magrittr', 'maps', 'miniUI', 'mockr', 'modeltools', 'msigdbr', 'nanoarrow', 'openssl', 'parallelly', 'patchwork', 'pbapply', 'pbkrtest', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'pkgload', 'plotly', 'progressr', 'promises', 'ps', 'psych', 'purrr', 'R.cache', 'R.oo', 'ragg', 'Rcpp', 'RcppArmadillo', 'RcppParallel', 'reformulas', 'ResidualMatrix', 'restfulr', 'reticulate', 'rlang', 'roxygen2', 'rprojroot', 'rsample', 'RSQLite', 'RUnit', 'rvest', 's2', 'sass', 'scatterpie', 'SCpubr', 'sctransform', 'SeuratObject', 'sf', 'shiny', 'spacesXYZ', 'spatstat', 'spatstat.data', 'spatstat.explore', 'spatstat.geom', 'spatstat.linnet', 'spatstat.model', 'spatstat.random', 'spatstat.univar', 'spatstat.utils', 'spdep', 'stringr', 'survminer', 'svglite', 'systemfonts', 'tensor', 'terra', 'textshaping', 'TH.data', 'tibble', 'tinytex', 'usethis', 'utf8', 'V8', 'vroom', 'waldo', 'xfun', 'xgboost', 'XML', 'xml2', 'yulab.utils', 'zip', 'zoo' Update all/some/none? [a/s/n]: n > library(kableExtra) # For table formatting 载入程序包:‘kableExtra’ The following object is masked from ‘package:dplyr’: group_rows > library(Seurat) # Seurat object > metadata <- read.csv( "Run5961_PDAC_Slide1_metadata_file.csv", header = TRUE) > exprMat <- read.csv("Run5961_PDAC_Slide1_exprMat_file.csv", row.names = 1 ) 错误于read.table(file = file, header = header, sep = sep, quote = quote, : 'row.names'里不能有重复的名称 > exprMat <- read.csv("Run5961_PDAC_Slide1_exprMat_file.csv", header = TRUE) > head(fov_positions) fov x_global_px y_global_px 1 31 -167790.5 60037.54 2 33 -168926.1 50800.38 3 35 -167131.8 36894.30 4 34 -166881.8 32628.33 5 30 -153631.6 35808.63 6 45 -143096.8 38916.08 > > metadata[1:6,1:6] fov cell_ID Area AspectRatio CenterX_local_px CenterY_local_px 1 1 1 10063 1.39 93 4209 2 1 2 2783 1.43 1214 4232 3 1 3 7246 2.34 2498 4223 4 1 4 8318 1.35 2769 4211 5 1 5 4371 1.10 3226 4221 6 1 6 6603 1.41 3009 4217 > > cells_0 <- grep("_0$", rownames(exprMat), value = TRUE) > > negPrb_col <- grep("^Neg", colnames(exprMat), value = TRUE) # Neg columns > > sysCon_col <- grep("^SystemControl", colnames(exprMat), value = TRUE) # SystemControl columns > > as.matrix(exprMat[1:6, 1:10]) fov cell_ID RAMP2 CD83 RYK CD5L NLRP2 BIRC5 LIF H2AZ1 1 1 0 13 59 36 33 20 26 54 84 2 1 1 0 0 1 1 0 1 1 0 3 1 2 0 0 0 0 0 0 0 0 4 1 3 1 0 0 0 0 0 0 0 5 1 4 0 0 0 0 0 0 0 0 6 1 5 0 0 0 0 0 0 0 0
最新发布
09-28
<think>我们收到了一个关于在R语言中处理空间转录组数据时遇到的各种错误的问题。用户提到了几个具体问题: 1. 使用`read.csv`读取文件结果与参考代码不同 2. 使用`ReadNanostring`加载数据时出现问题 3. 手动构建Seurat对象时遇到错误,包括参数无用、找不到对象、重复行名、函数未找到等 我们将逐一分析并提供解决方案。 ### 1. `read.csv`读取文件结果与参考代码不同 **可能原因及解决方案:** - **文件路径错误**:确保文件路径正确。使用绝对路径或相对路径(推荐使用`here`包构建路径)[^1]。 ```r # 使用here包构建路径示例 library(here) file_path <- here("data", "your_file.csv") data <- read.csv(file_path) ``` - **文件编码问题**:某些文件可能使用非UTF-8编码(如Windows系统的CP1252)。指定`fileEncoding`参数。 ```r data <- read.csv("your_file.csv", fileEncoding="UTF-8") # 或尝试其他编码,如"latin1", "CP1252" ``` - **分隔符问题**:CSV文件可能使用非逗号分隔符(如制表符)。使用`read.delim`或指定`sep`参数。 ```r data <- read.delim("your_file.csv", sep=",") # 等同于read.csv # 如果是制表符分隔,则使用sep="\t" ``` - **标题行问题**:如果第一行不是列名,设置`header=FALSE`;如果数据有列名但参考代码没有,则可能不一致。 ```r data <- read.csv("your_file.csv", header=FALSE) # 无列名 ``` - **字符串作为因子**:R的旧版本默认将字符串转为因子,可能会导致后续分析出错。设置`stringsAsFactors=FALSE`。 ```r data <- read.csv("your_file.csv", stringsAsFactors=FALSE) ``` - **数值格式问题**:如千位分隔符、小数点为逗号等。使用`dec`和`comment.char`等参数调整。 ```r data <- read.csv("your_file.csv", dec=",", comment.char="") # 小数点为逗号,无注释字符 ``` - **行名问题**:如果第一列是行名,使用`row.names`参数指定。 ```r data <- read.csv("your_file.csv", row.names=1) # 将第一列作为行名 ``` - **空白字符**:自动去除字符串前后空白,可使用`strip.white=TRUE`(但`read.csv`默认不会去除,可能需要额外处理)。 ### 2. `ReadNanostring`加载数据时出现问题 `ReadNanostring`是NanoStringNorm包中的函数,用于读取NanoString数据。常见问题: - **包未安装**:确保已安装`NanoStringNorm`包。 ```r install.packages("NanoStringNorm") library(NanoStringNorm) ``` - **文件格式错误**:确保文件是NanoString支持的格式(如RCC格式)。检查文件路径和文件名。 - **参数错误**:查看函数文档,确认参数是否正确。常用参数包括`dir`(目录)、`files`(文件列表)等。 ```r # 示例:读取单个文件 data <- ReadNanostring("your_file.RCC") ``` - **函数未找到**:如果出现`could not find function "ReadNanostring"`,可能是包未正确加载或函数名拼写错误(注意大小写)。正确函数名为`read.nanostring`(小写)?检查文档确认。 实际在NanoStringNorm包中,函数是`read.markup.RCC`(用于读取RCC文件)或`read.xlsx.RCC`(用于读取Excel格式)。请确认函数名[^2]。 ```r ?read.markup.RCC # 查看帮助 ``` ### 3. 手动构建Seurat对象时遇到的问题 创建Seurat对象通常使用`CreateSeuratObject`函数。常见错误: - **参数无用(not used)**:可能是参数拼写错误或参数在函数版本中已弃用。例如: ```r # 错误:object 'project' not found seurat_obj <- CreateSeuratObject(counts = exprMat, project = "MyProject") ``` 在旧版本Seurat中,`project`参数可能不存在(新版本存在)。请检查Seurat版本和函数文档: ```r ?CreateSeuratObject ``` 解决方案:升级Seurat到最新版,或使用正确参数(如`project`在Seurat v3+中有效)。若版本低,可使用`project.name`(已弃用)。 - **找不到对象(object not found)**:确保传入的`counts`矩阵已正确定义且存在于环境中。 ```r # 假设exprMat是表达矩阵 seurat_obj <- CreateSeuratObject(counts = exprMat) ``` 如果`exprMat`不存在,会报错。请检查拼写。 - **重复行名(duplicate rownames)**:表达矩阵的行名(基因名)不能重复。 - 解决方案:去重或修改行名。 ```r # 去重方法1:保留重复基因的第一行 exprMat <- exprMat[!duplicated(rownames(exprMat)), ] # 方法2:使用聚合函数(如取平均值) # 假设有重复行名,使用aggregate函数 exprMat_agg <- aggregate(. ~ gene, data=exprMat, FUN=mean) # 需要将行名转为列 # 或者使用dplyr library(dplyr) exprMat_agg <- exprMat %>% mutate(gene = rownames(.)) %>% group_by(gene) %>% summarise_all(mean) %>% column_to_rownames("gene") ``` - **函数未找到**:未加载Seurat包。 ```r library(Seurat) ``` 如果未安装,先安装: ```r install.packages("Seurat") ``` 注意:Seurat的某些函数可能在子包中(如`SeuratObject`),确保安装正确版本。 - **其他常见错误**: - **表达矩阵类型**:`counts`必须是矩阵或dgCMatrix(稀疏矩阵)。如果是数据框,需转换: ```r exprMat <- as.matrix(exprMat) # 转换为矩阵 # 或转换为稀疏矩阵 exprMat <- as(exprMat, "sparseMatrix") ``` - **空行或空列**:Seurat默认会过滤掉没有检测到任何基因的细胞(列)和在任何细胞中都不表达的基因(行)。可以通过`min.cells`和`min.features`参数调整。 ```r seurat_obj <- CreateSeuratObject(counts = exprMat, min.cells=3, min.features=200) ``` ### 总结 以上针对用户提出的三类问题提供了详细的解决方案。在R中处理空间转录组数据时,注意文件路径、编码、格式以及函数参数的正确性。同时,确保使用最新的包版本并参考官方文档。 §§相关问题§§ 1. 如何检查R中函数的参数以避免“参数无用”错误? 2. 在读取CSV文件时,如何自动检测文件的编码? 3. 在构建Seurat对象时,如何处理基因名重复的问题? 4. 如何更新R包到最新版本以确保函数兼容性? [^1]: R语言中文件路径的处理方法,参考《R Data Import/Export》手册。 [^2]: NanoStringNorm包文档,详见`?read.markup.RCC`。 </think>以下是针对R语言中空间转录组数据处理常见错误的系统性解决方案,结合`read.csv`、`ReadNanostring`和Seurat对象构建中的典型问题: ### 一、`read.csv`读取结果不一致问题 **原因与解决方案**: 1. **文件编码问题**: 使用`fileEncoding`参数指定正确编码(如UTF-8或Latin1): ```r data <- read.csv("file.csv", fileEncoding = "UTF-8") # 中文数据用GB18030 ``` 2. **分隔符错误**: 检查实际分隔符(制表符、分号等),使用`sep`参数: ```r data <- read.csv("file.csv", sep = "\t") # 制表符分隔 ``` 3. **自动类型转换干扰**: 禁用自动转换,后续手动处理类型: ```r data <- read.csv("file.csv", stringsAsFactors = FALSE, colClasses = "character") # 全部读为字符型 ``` 4. **首行元数据干扰**: 跳过非标题行: ```r data <- read.csv("file.csv", skip = 3) # 跳过前3行 ``` ### 二、`ReadNanostring`错误解决方案 **常见问题处理**: ```r # 安装最新版包 if (!require("NanoStringNCTools")) remotes::install_github("Nanostring-Biostats/NanoStringNCTools") library(GeomxTools) # 官方推荐包 # 正确加载数据 dsp_data <- readNanoStringGeoMxSet( dccFiles = dir("dcc_dir", full.names = TRUE), pkcFiles = "panel.pkc", phenoDataFile = "metadata.csv" ) ``` **错误排查**: 1. **函数未找到**: 确保使用`GeomxTools::readNanoStringGeoMxSet()`完整调用 2. **参数无用警告**: 检查参数大小写:`.dccFiles` ≠ `dccFiles` 3. **文件路径错误**: 使用`normalizePath()`验证路径: ```r dcc_dir <- normalizePath("dcc_dir") # 转换绝对路径 ``` ### 三、Seurat对象构建错误处理 **正确构建流程**: ```r library(Seurat) # 1. 解决行名重复问题 rownames(exprMat) <- make.unique(rownames(exprMat)) # 基因名去重 # 2. 创建对象 seurat_obj <- CreateSeuratObject( counts = exprMat, # 表达矩阵 meta.data = metadata, # 元数据 project = "Spatial_Proj", # 项目名 min.cells = 3, # 基因最少出现细胞数 min.features = 200 # 细胞最少检测基因数 ) # 3. 添加空间坐标 spatial_coords <- fov_positions[, c("x", "y")] seurat_obj@images$slice1 <- new( Class = "VisiumV1", coordinates = spatial_coords ) ``` **典型错误处理**: | 错误类型 | 解决方案 | |-------------------------|------------------------------------------| | `找不到对象` | 检查对象是否存在:`exists("exprMat")` | | `重复行名` | 使用`make.unique(rownames())`处理基因名 | | `参数无用` | 核对最新文档:`?CreateSeuratObject` | | `函数未找到` | 更新Seurat:`remotes::install_github("satijalab/seurat")` | | `维度不匹配` | 验证:`nrow(metadata) == ncol(exprMat)` | ### 四、最佳实践建议 1. **内存优化**: ```r # 使用data.table读取大文件 library(data.table) metadata <- fread("metadata.csv", header = TRUE) # 稀疏矩阵存储 exprMat <- Matrix(as.matrix(exprMat), sparse = TRUE) ``` 2. **数据验证**: ```r # 检查维度一致性 stopifnot( nrow(fov_positions) == ncol(exprMat), nrow(metadata) == ncol(exprMat) ) ``` 3. **版本控制**: ```r packageVersion("Seurat") # 推荐 ≥ 4.3.0 ``` > **关键点**:空间转录组数据处理需保证三个核心数据的一致性: > $$ \text{dim}(\text{exprMat})[2] = nrow(\text{fov\_positions}) = nrow(\text{metadata}) $$ > 其中 $\text{dim}(\text{exprMat})[2]$ 表示细胞/点数量[^1]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值