Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seurat has changed functions for reduced dims #5

Open
hypercompetent opened this issue May 1, 2019 · 0 comments
Open

Seurat has changed functions for reduced dims #5

hypercompetent opened this issue May 1, 2019 · 0 comments

Comments

@hypercompetent
Copy link

The current version of the make_seurat() function in clustering/clustering.R doesn't work on the current version of Seurat because of changes to Seurat functions. This version uses the updated CreateDimReducObject() function, and seems to work with what I've tested so far:

make_seurat = function(atac_matrix, metadata=NULL, pca_coords=NULL, tsne_coords=NULL) {
  if (is.null(pca_coords) && is.null(tsne_coords)) {
    stop('One of pca_coords or tsne_coords (or both) must be set to make the fake seurat object.')
  }
  
  if (!is.null(metadata)) {
    seurat_obj = CreateSeuratObject(atac_matrix, meta.data=metadata, project='DEFAULT', min.cells=0, min.features=0)
  } else {
    seurat_obj = CreateSeuratObject(atac_matrix, project='DEFAULT', min.cells=0, min.features=0)
  }
  
  if (!is.null(pca_coords)) {
    pca_coords = as.matrix(pca_coords)
    seurat_obj[["pca"]] <- CreateDimReducObject(embeddings = pca_coords,
                                                assay = DefaultAssay(object = seurat_obj),
                                                key = "PCA_")
  }
  
  if (!is.null(tsne_coords)) {
    tsne_coords = as.matrix(tsne_coords)
    seurat_obj[["tsne"]] <- CreateDimReducObject(embeddings = tsne_coords,
                                                 assay = DefaultAssay(object = seurat_obj),
                                                 key = "TSNE_")
    
  }
  
  return(seurat_obj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant