Hi all,
I have a Seurat object with two assays ("Nanostring" and "metadata") and if I run the PCA/UMAP first on "Nanostring" and then on "metadata", the "metadata" PCA/UMAP overwrites the one generated from the "Nanostring" assay. How can save multiple PCAs/UMAPs from different assays in a single seurat object?
Here is the code I use to generate the PCA/UMAP for the "Nanostring" assay:
# Normalize the count data present in a given assay
patient_rna_only <- Seurat::NormalizeData(patient_rna_only, assay = "Nanostring")
# Scales and centers features in the dataset
patient_rna_only <- Seurat::ScaleData(patient_rna_only)
# Detect highly variable genes for the pca
# Identifies features that are outliers on a 'mean variability plot'
patient_rna_only <- Seurat::FindVariableFeatures(patient_rna_only)
# Run a PCA dimensionality reduction
patient_rna_only <- Seurat::RunPCA(patient_rna_only, seed.use = 1)
# Computes the k.param nearest neighbors
patient_rna_only <- Seurat::FindNeighbors(patient_rna_only, dims = patient_dims)
# Identify clusters of cells by a shared nearest neighbor (SNN) modularity optimization based clustering algorithm
# Use the resolution parameter to fine tune the number of expected clusters
patient_rna_only <- Seurat::FindClusters(
patient_rna_only,
resolution = patient_res,
random.seed = 1,
cluster.name = "Seurat_clusters")
# Uniform Manifold Approximation and Projection (UMAP) dimensional reduction technique
patient_rna_only <- Seurat::RunUMAP(patient_rna_only, dims = patient_dims, repulsion.strength = 5, seed.use = 1)
And here is what I tried to save the second PCA/UMAP somewhere else:
# Run PCA and specify the number of PCs to compute
# Only 10 features available, use 10 PCs
n_pcs <- 9
patient_data[['proteins']] <- RunPCA(patient_data, assay = "metadata", features = features_to_scale, npcs = n_pcs)
# Use the available number of PCs for FindNeighbors and clustering
patient_data <- FindNeighbors(patient_data, dims = 1:n_pcs, assay = "metadata")
patient_data <- FindClusters(patient_data, resolution = 0.5, assay = "metadata")
# Run UMAP for visualization
patient_data[['proteins']] <- RunUMAP(patient_data, dims = 1:n_pcs, assay = "metadata")
But obviously this does not work. Please be patient as I am very new to R and Seurat.
Thank you very much, Alberto