R Major Troubleshooting [01-20]
Recommended post : 【R STUDIO】 R Studio Table of Contents
1. Error: attempt to use zero-length variable name
⑴ (grammar) Cause : When there are characters like ```
2. Error: cannot allocate vector of size 4.9 Gb
⑴ (system) Cause : The process exceeds the memory limit
① Memory demand is usually high during data analysis
② The memory limit set using memory.limit cannot exceed the RAM memory of the PC
③ Task Manager → Performance → Memory
○ Check the total capacity of the memory
○ Checking used slots and purchasing additional RAM could be a solution
○ (Note) For data analysis, it seems like having 32 GB of RAM is necessary
⑵ (grammar) Solution (Version 4.1.x or earlier)
①
memory.limit(size = 50000)
② # Increase the maximum memory limit of the computer to about 49GB
③ The above command is only applicable in Windows
⑶ (grammar) Solution (Version 4.2.x or later)
① “memory.limit() is no longer supported” error message occurs
② In this case, you can increase R’s maximum memory limit as follows (Reference)
library(usethis)
usethis::edit_r_environ()
# Then, type "R_MAX_VSIZE=100Gb" and save .Renviron file.
③ However, in Windows R 4.2.x and above versions, memory is automatically increased, so there is no need to worry separately (Reference)
④ Note that these measures are effective on M1 MacBook Air or MacBook Pro
3. Error: .onLoad failed in loadNamespace() for ‘Cairo’, details: call: dyn.load(file, DLLpath = DLLpath, …) error: unable to load shared object ‘Library Frameworks R.framework Versions 4.1 Resources library Cairo libs Cairo.so’: dlopen(Library Frameworks R.framework Versions 4.1 Resources library Cairo libs Cairo.so, 0x0006): Library not loaded: opt X11 lib libXrender.1.dylib Referenced from: Library Frameworks R.framework Versions 4.1 Resources library Cairo libs Cairo.so Reason: tried: ‘opt X11 lib libXrender.1.dylib’ (no such file), ‘Library Frameworks R.framework Resources lib libXrender.1.dylib’ (no such file), ‘Users parkjeongbin lib libXrender.1.dylib’ (no such file), ‘usr local lib libXrender.1.dylib’ (no such file), ‘usr lib libXrender.1.dylib’ (no such file), ‘lib libXrender.1.dylib’ (no such file), ‘Library Java JavaVirtualMachines jdk1.8.0_241.jdk Contents Home jre lib server libXrender.1.dylib’ (no such file), ‘var folders rt qbr8l3sj73zd871cg_jmqrcm0
⑴ (package) Cause : XQuartz no longer provided on MacBooks
⑵ (package) Solution : Install XQuartz from https://www.xquartz.org/
⑶ Reference : https://stackoverflow.com/questions/38952427/include-cairo-r-on-a-mac
4. ERROR: lazy loading failed for package ‘SeuratWrappers’
⑴ (package) Situation : Problem occurs when running remotes::install_github('satijalab/seurat-wrappers')
⑵ (package) Cause 1. If R.utils is not installed, solve it by installing with install.packages("R.utils")
⑶ (package) Cause 2. https://github.com/satijalab/seurat-wrappers/issues/32
5. warning message: In normalizePath(path.expand(path), winslash, mustwork): path [1]=”C: Users ??? Documents” : file name, directory name, or volume label syntax is incorrect
⑴ (system) Cause : When the username contains Korean characters
⑵ (system) Solution 1. Change the username to English
⑶ (system) Solution 2. Change the working directory path using setwd or R Studio
⑷ This issue is not a big problem in R, but it can be problematic in Python
6. there is no package called ‘ifnb.SeuratData’
⑴ (package) Solution
install.packages("https://seurat.nygenome.org/src/contrib/ifnb.SeuratData_3.0.0.tar.gz", repos = NULL, type = "source")
⑵ Reference : https://github.com/satijalab/seurat-data/issues/15
**7. RStudio requires an existing installation of R in order to work. Please select the version of R to use. **
⑴ (others) Solution
**8. The procedure entry point quadmath_snprintf could not be located in the dynamic link library C:\Users\USER\anaconda3\envs\MY_ENV\Lib\R\library\igraph\libs\x64\igraph.dll **
⑴ (package) Cause : The igraph.dll provided by CRAN assumes that Rlapack.dll provides the quadmath_snprintf function, but Anaconda R does not have the quadmath_snprintf function for some reason
⑵ (package) Solution : Install igraph using conda-forge
⑶ Reference : https://igraph.discourse.group/t/rterm-exe-entry-point-not-found/1326/3
9. “Error: Cannot allocate vector with size 13.3 GB”
⑴ (grammar) Solution
**10. Error in .testForValidKeys(x, keys, keytype, fks) : None of the keys entered are valid keys for ‘SYMBOL’. Please use the keys method to see a listing of valid arguments. **
⑴ (grammar) Issue : Using mouse genes instead of human genes in situations where human genes are required, using ENSG, ENSMUSG codes instead of gene names, etc.
⑵ (grammar) Example of solution
# before
gene.df <- bitr(MY_GENE_LIST,
fromType = "SYMBOL",
toType = c("ENSEMBL", "SYMBOL","ENTREZID"),
OrgDb = org.Hs.eg.db)
# after
gene.df <- bitr(MY_GENE_LIST,
fromType = "SYMBOL",
toType = c("ENSEMBL", "SYMBOL","ENTREZID"),
OrgDb = org.Mm.eg.db)
11. Error in library(“clusterProfiler”) : there is no package called ‘clusterProfiler’
⑴ (grammar) Issue : On a MacBook, some packages often cause problems when only using install.package and BiocManager::install
⑵ (grammar) Solution : Instead of using RStudio, run the following code from CRAN
install.packages('RSQLite', dependencies = TRUE, force = TRUE)
BiocManager::install('HDO.db', dependencies = TRUE, force = TRUE)
install.packages('graphlayouts', dependencies = TRUE, force = TRUE)
BiocManager::install('clusterProfiler', dependencies = TRUE, force = TRUE)
⑶ Common solutions when install.packages causes problems
① Install from CRAN instead of R studio
② Run delete.packages(‘devtools’) and then install.packages(‘devtools’)
③ Reinstall R studio
④ Try on a different computer
⑤ Use additional arguments like install.packages(“devtools”, repos = NULL, type = “source”)
⑥ Use additional arguments like install.packages(‘devtools’, dependencies = TRUE, force = TRUE)
⑦ Get the library folder itself and paste it in the appropriate location within the desired PC
⑧ Increase timeout time with code like options(timeout=300)
12. Error in sum(dim(scRNAseqData)): argument “b” is missing, with no default
⑴ (grammar) Issue : Appears to be a collision when importing functions using the source statement, but it’s preferable to define necessary functions one by one rather than using source
source("https://github.com/JB243/nate9389/blob/main/RStudio/A_Collection_of_Useful_Functions_in_RStudio.R?raw=true")
⑵ (grammar) Solution : Instead of importing functions with source, define the necessary functions individually
⑶ A similar issue arises with “do.call” r argument “b” is missing, with no default
13. Error in AddMetaData.Seurat(br.sp, pathways) : ‘col.name’ must be provided for atomic metadata types (eg. vectors)
⑴ (grammar) Issue : When pathways is of inappropriate data type, such as a double type variable
pathways <- as.data.frame(pathways)
br.sp <- AddMetaData(br.sp, pathways)
⑵ (grammar) Solution
14. Error in dimnames(x) <- dn : ‘dimnames’ applied to non-array
⑴ (grammar) Issue : Currently, there is no way to change colnames of Seurat objects (Reference)
⑵ (grammar) Solution 1. Define a new Seurat object with different colnames (Reference)
⑶ (grammar) Solution 2. Modifying orig.ident can have a similar effect
object$orig.ident <- c('C', 'A', 'B')
# reordering
object$orig.ident <- factor(x = object$orig.ident, levels = c('A', 'B', 'C'))
15. Error in tmp[“CD34”, ]: invalid or not-yet-implemented ‘Matrix’ subsetting
⑴ (grammar) Issue : tmp variable is not a matrix. This problem can arise with sparse matrices
⑵ (grammar) Solution : Convert the tmp variable to matrix type
tmp = as.matrix(tmp)
16. Error in file(file, “rt”) : invalid ‘description’ argument
⑴ (grammar) Cause : Error occurs when Load10X_Spatial is used, and the cause is having both tissue_positions_list.csv and tissue_positions.csv files in the spatial folder (only one should be present)
17. Error in intI(i, n = d[1L], dn[[1L]], give.dn = FALSE) : invalid character indexing
⑴ (grammar) Cause 1. Problem occurs in Seurat pipeline when trying to overlay different matrix values on object@assays$RNA@data
and object@assays$RNA@scale.data
, and subtyping with object_ = object[, c(1:10)]
⑵ (grammar) Cause 2. Problem occurs when doing pbmc_ = pbmc[gene_list, ]
and the gene_list contains underscores (_) (Examples)
① Example 1. C4B_2
② Example 2. GTF2H2C_2
③ Example 3. XLOC_008559
④ Example 4. XLOC_009911
⑤ Example 5. 18S_rRNA
18. Error in rownames<-
(*tmp*
, value = “Tumor_0-0Gy_1”) : attempt to set ‘rownames’ on an object with no dimensions
⑴ (grammar) Cause : When trying to assign a value to a factor type variable that is not a specific level, an error occurs
⑵ (grammar) Solution
# Example
library(compGenomRData)
coldata_file <- system.file ("extdata/rna-seq/SRP029880.colData.tsv", package = "compGenomRData")
colData <- read.table(coldata_file, header = T, sep = '\t',
stringsAsFactors = TRUE)
colData$source_name <- as.character(colData$source_name)
colData$group <- as.character(colData$group)
## Exemplary edition of the given data
colData[1,1] = "A"
colData[1,2] = "B"
colData$source_name <- as.factor(colData$source_name)
colData$group <- as.factor(colData$group)
19. Warning message: In read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on ‘my_data.csv’
⑴ (grammar) Solution : Use suppressWarnings
# Before
df <- read.csv('my_data.csv')
# After
df <- suppressWarnings(read.csv('my_data.csv'))
20. When RStudio is opened on a MacBook, only a blank screen appears
⑴ Issue situation
⑵ (system) Cause : When there are folders with Korean names in addition to the default folder in RStudio workplace
⑶ (system) Solution : Change the folder names in RStudio workplace to English (except for the default folder)
Input : 2022.01.29 17:33
Modified : 2023.06.02 18:13