Created
April 14, 2023 02:12
-
-
Save jebard/d72d4e7081ac41386986b4100a50ed79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Seurat) | |
## Prep for 10x loupe browser inegration | |
seurat.object | |
### first we need to extract out the seurat cell barcodes and convert them back into Loupe space | |
### note this is tested on integrated objects in seurat with multi samples | |
seurat.object$loupe_barcodes <- gsub(names(Idents(seurat.object)),pattern = "-1_",replacement = "-") | |
## pull the embeddings from UMAP | |
embeds <- (seurat.object@[email protected]) | |
rownames(embeds) <- seurat.object$loupe_barcodes | |
write.csv(file="loupe-files/umap.embeddings.csv", | |
embeds, | |
row.names = T,col.names = F,quote = F) | |
## next we want to grab the clustering and save that out | |
loupe_clusts <- data.frame(seurat.object$seurat_clusters) | |
rownames(loupe_clusts) <- seurat.object$loupe_barcodes | |
write.csv(file="loupe-files/umap.clustering.csv", | |
loupe_clusts, | |
row.names = T,col.names = F,quote = F) | |
## barcode to our custom labels | |
loupe_labels <- data.frame(Idents(seurat.object)) | |
rownames(loupe_labels) <- seurat.object$loupe_barcodes | |
write.csv(file="loupe-files/umap.cellTypeLabel.csv", | |
loupe_labels, | |
row.names = T,col.names = F,quote = F) | |
## lastly sample + cell type | |
seurat.object$id_type <- paste0(Idents(seurat.object),"-",seurat.object$orig.ident) | |
loupe_ids <- data.frame(seurat.object$id_type) | |
rownames(loupe_ids) <- seurat.object$loupe_barcodes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment