Question: I am using LoupeR to convert a Seurat Object into a .cloupe file. I am getting the error message: "all values must be less than 32767". What does this mean?
Answer: Loupe Browser supports a maximum of 32,768 different values (list of factors) for the selected metadata. For example, when selecting clusters from your Seurat object, LoupeR will produce this error if any of your clusters found in the metadata of the Seurat Object have more than 32,768 values in the list. A common source of this error is when a cluster contains a unique name for every cell - often one of the "idents" found in the metadata of the Seurat Object.
The path mentioned in the full error message (for example:"/clusters/cells/assignments"
) tells you which metadata exceed the maximum of 32,768 values. In the example case, it is metadata called "cells". The solution here is to remove the unsupported metadata "cells" from the Seurat Object.
Below is some example code for extracting only metadata that have fewer than 32,768 values from a Seurat Object and generating a .cloupe file using create_loupe
:
# import the library
library("loupeR")
# Gene Expression RNA assay
assay <- seurat_obj[["RNA"]]
# select clusters and filter those that have too many names/levels
clusters <- select_clusters(seurat_obj)
clusters <- clusters[lapply(clusters, nlevels) < 32768]
# convert the count matrix, clusters, and projections into a Loupe file
create_loupe(
assay@counts,
clusters = clusters,
projections = select_projections(seurat_obj)
)