Search code examples
rbioinformaticsseurat

R convert data into a vector


I have an object (Seurat object) an I need to get certain data out of it

> sc@misc[["colors"]][["seurat_clusters"]]
          0           1           2           3           4           5           6           7 
"#CC0C00FF" "#5C88DAFF" "#84BD00FF" "#FFCD00FF" "#7C878EFF" "#00B5E2FF" "#00AF66FF" "#CC0C00B2" 

This data is needed as an vector but I don't know how to pull "#CC0C00FF" "#5C88DAFF" etc. out of it.

In order to hand this data to the next function, the result should look like this:

> vec
[1] "#CC0C00FF" "#5C88DAFF" "#84BD00FF"

Thanks in advance!


Solution

  • Solved it! I'm pretty disappointed by myself, because I didn't know this function existed:

    > as.vector(sc@misc[["colors"]][["seurat_clusters"]])
    [1] "#CC0C00FF" "#5C88DAFF" "#84BD00FF" "#FFCD00FF" "#7C878EFF" "#00B5E2FF" "#00AF66FF" "#CC0C00B2"