Skip to content

Seurat has changed functions for reduced dims #5

Description

@hypercompetent

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions