Comments (4)
Hi Stephen,
I updated Jeffrey's SeuratToURD function to import the Seurat (v3) object into URD. I'm just testing it now and haven't encountered any issues so far. You'll have to create a custom function - in this case I named it seuratToURD2 - and then use that one to import your seurat object. Here's the code:
seuratToURD2 <- function(seurat.object) {
if (requireNamespace("Seurat", quietly = TRUE)) {
# Create an empty URD object
ds <- new("URD")
# Copy over data
[email protected] <- as(as.matrix(seurat.object@assays$RNA@data), "dgCMatrix")
if(!any(dim(seurat.object@assays$RNA@counts) == 0)) [email protected] <- as(as.matrix(seurat.object@assays$RNA@counts[rownames(seurat.object@assays$RNA@data), colnames(seurat.object@assays$RNA@data)]), "dgCMatrix")
# Copy over metadata
## TO DO - grab kmeans clustering info
get.data <- NULL
if (.hasSlot(seurat.object, "data.info")) {
get.data <- as.data.frame(seurat.object@[email protected])
} else if (.hasSlot(seurat.object, "meta.data")) {
get.data <- as.data.frame([email protected])
}
if(!is.null(get.data)) {
di <- colnames(get.data)
m <- grep("res|cluster|Res|Cluster", di, value=T, invert = T) # Put as metadata if it's not the result of a clustering.
discrete <- apply(get.data, 2, function(x) length(unique(x)) / length(x))
gi <- di[which(discrete <= 0.015)]
ds@meta <- get.data[,m,drop=F]
[email protected] <- get.data[,gi,drop=F]
}
# Copy over var.genes
if(length(seurat.object@[email protected] > 0)) [email protected] <- seurat.object@[email protected]
# Move over tSNE projection
if (.hasSlot(seurat.object, "tsne.rot")) {
if(!any(dim([email protected]) == 0)) {
[email protected] <- as.data.frame([email protected])
colnames([email protected]) <- c("tSNE1", "tSNE2")
}
} else if (.hasSlot(seurat.object, "reductions")) {
if(("tsne" %in% names(seurat.object@reductions)) && !any(dim(seurat.object@reductions$tsne) == 0)) {
[email protected] <- as.data.frame(seurat.object@[email protected])
colnames([email protected]) <- c("tSNE1", "tSNE2")
}
}
# Move over PCA results
if (.hasSlot(seurat.object, "pca.x")) {
if(!any(dim([email protected]) == 0)) {
[email protected] <- [email protected]
[email protected] <- [email protected]
warning("Need to set which PCs are significant in @pca.sig")
}
## TO DO: Convert SVD to sdev
} else if (.hasSlot(seurat.object, "reductions")) {
if(("pca" %in% names(seurat.object@reductions)) && !any(dim(Loadings(seurat.object, reduction = "pca")) == 0)) {
[email protected] <- as.data.frame(Loadings(seurat.object, reduction = "pca"))
[email protected] <- as.data.frame(seurat.object@[email protected])
[email protected] <- seurat.object@reductions$pca@stdev
[email protected] <- pcaMarchenkoPastur(M=dim([email protected])[1], N=dim([email protected])[1], [email protected])
}
}
return(ds)
} else {
stop("Package Seurat is required for this function. To install: install.packages('Seurat')\n")
}
}
from urd.
There is a function seuratToURD
that should work with Seurat v2. I have not yet updated it for Seurat v3, and I believe the structure of the object changed there. You would then need to do all steps beginning with Calculate Diffusion Map in the QuickStart tutorial. The method that URD uses to calculate variable genes is different from Seurat, so you may also want to explore URD's variable gene results and compare them to those from Seurat. Additionally, if you didn't calculate a tSNE representation in Seurat, you may want to calculate one in URD just for visualization and exploration. Clustering wise, I generally cluster at each stage individually, though you could try exploring both methods.
from urd.
Thanks, Augustin! I will incorporate this into the code base soon & add an acknowledgment to you in the documentation & homepage.
from urd.
Thanks Stephen - really helpful!
from urd.
Related Issues (20)
- Link to processed URD object is out of date
- gene cascade heatmap
- macOS: Can't install because of package 'destiny' HOT 1
- error when installing destiny HOT 1
- Cholmod error HOT 1
- Supplementary Analysis Count and Meta data files out of date on Broad SC Portal
- n_pcs is needed to be specified in calcDM
- floodPseudotime HOT 1
- Markers for Trajectory Branches.
- Error in calcTsne and calcDM: length of 'dimnames' [1] not equal to array extent HOT 2
- aucprTestByFactor
- determine.timing: Error in peak.rle[peak, "start"]:peak.rle[peak, "end"] : NA/NaN argument
- where is walks.to.do object
- Error in visit.data[cells.in.tip, ] : incorrect number of dimensions
- Error in floodPseudotimeProcess HOT 2
- Installation: big trouble in many packages
- SupplementaryAnalysis.pdf --- Page 19 --- Batch correct data --- mnnCorrect
- what is tip.walk.files?
- Set two roots?
- limit.single.sigmoid.slopes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urd.