8.5 Importing an embedding from external software

If you have analyzed data using another package, you can always import your embedding coordinates into ArchR. To do this, you need to create the various attributes that ArchR expects of an embedding and then add this to the embeddings slot of your ArchRProject.

The key component of an embedding in ArchR is a DataFrame that contains the cell names and the embedding coordinates of each cell. In the below example, we will randomly generate arbitrary UMAP coordinates for all of the cells in projHeme5 but in your own application you would need to provide UMAP coordinates ordered in the same order as returned by getCellNames().

#simulate mock UMAP data by random sampling
umap1 <- (sample(x = -100000:100000, size = length(getCellNames(projHeme2)), replace = FALSE))/10000
umap2 <- (sample(x = -100000:100000, size = length(getCellNames(projHeme2)), replace = FALSE))/10000

#add embedding to projHeme2
umap_df <- DataFrame(row.names = getCellNames(projHeme2), "custom#UMAP1" = umap1, "custom#UMAP2" =  umap2, check.names = FALSE)
projHeme2@embeddings$customUMAP <- SimpleList(df = umap_df, params = list())

With this, we would be able to use this embedding by name as with any other embedding in our ArchRProject. It is important to note that the embedding coordinate column names (i.e "custom#UMAP1" and "custom#UMAP2" in the example above) must contain the # in the name as this is used in string splitting operations in plotEmbedding() and other functions.

getEmbedding(ArchRProj = projHeme2, embedding = "customUMAP")
## DataFrame with 10250 rows and 2 columns
##                                   custom#UMAP1 custom#UMAP2
##                                      <numeric>    <numeric>
## scATAC_BMMC_R1#TTATGTCAGTGATTAG-1       8.0523       4.0882
## scATAC_BMMC_R1#AAGATAGTCACCGCGA-1       9.5409      -1.0883
## scATAC_BMMC_R1#GCATTGAAGATTCCGT-1      -2.0659      -0.2871
## scATAC_BMMC_R1#TATGTTCAGGGTTCCC-1       7.0213       2.7621
## scATAC_BMMC_R1#TCCATCGGTCCCGTGA-1      -9.3855       7.6017
## ...                                        ...          ...
## scATAC_PBMC_R1#GCTGCGAAGATCCGAG-1       1.5187       0.0296
## scATAC_PBMC_R1#GCAGCTGGTGGCCTTG-1       0.0526      -9.3273
## scATAC_PBMC_R1#GCAGATTGTACGCAAG-1      -2.9732       4.4179
## scATAC_PBMC_R1#TTCGTTACATTGAACC-1      -5.9111       3.7804
## scATAC_PBMC_R1#CGCTATCGTGAGGTCA-1       0.5146      -2.9185