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

Bug on cluster annotation from Seurat object #13

Open
cbravo93 opened this issue Jan 28, 2020 · 0 comments
Open

Bug on cluster annotation from Seurat object #13

cbravo93 opened this issue Jan 28, 2020 · 0 comments

Comments

@cbravo93
Copy link
Member

cbravo93 commented Jan 28, 2020

Hi @dweemx !

I had some issues to annotate Seurat clusters with the add_seurat_clustering function; even when providing an annotation clusters would be only annotated numerically, and read into SCope as NDA - Cluster X (X). By changing some parts of the code it works now, and at least for the way I am creating looms doesn't seem to give issues:

  • add_seurat_clustering (lines 697-704)
#cluster.annotation<-create_cluster_annotation(clusters = cluster.ids, cluster.meta.data.df = a, cluster.id.cn = ac.id.cn,  cluster.description.cn = ac.description.cn) 
# NOT NEEDED!
clid<-add_annotated_clustering(loom = loom
                                     , group = "Seurat"
                                     , name = paste("Seurat,", paste0(seurat.clustering.prefix, res))
                                     , clusters = cluster.ids
                                     , annotation = annotation 
                                     #Pass directly annotation, not cluster.annotation
                                     , is.default = is.default.clustering
                                     , overwrite.default = default.clustering.overwrite)
  • add_annotated_clustering (lines 842-852)
# DON'T DO THIS, KEEP ANNOTATION AS IT IS
 #if(length(unique(clusters)) == length(unique(annotation))) {
    # Make sure the order are the same
   # annotation<-annotation[names(clusters)]
  #} else {
    # Does not seem that cluster IDs and cluster annotation correspond
    # Remap to have the same number of unique IDs as the number of unique annotation
   # library(plyr)
    #clusters<-factor(x = as.integer(mapvalues(annotation, from = unique(x = annotation), to = seq_along(along.with = unique(x = annotation))-1)))
    #names(clusters)<-names(annotation)
  #}
  • add_global_md_clustering (lines 229-236)
if(!is.null(annotation)) {
      # Force to have the same order
      #annotation<-annotation[names(clusters)]
      # If annotation for the current cluster not empty then add
      d<-as.vector(unlist(annotation[annotation[,1] == cluster.id, 2]))
      # ASSUMING CLUSTER NUMBER IN FIRST COLUMN AND ANNOT IN SECOND
      # Convert from factor to character vector to be used with nchar
      #d<-as.character(unique(annotation[clusters == cluster.id])) 

Cheers,

C

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