# Working with Multiple samples with PEAKVI

**URL:** <https://discourse.scverse.org/t/working-with-multiple-samples-with-peakvi/1390>\
**Category:** scvi-tools\
**Tags:** scatac-seq, scvi, peakvi\
**Created:** [May 5, 2023, 2:31pm UTC](https://discourse.scverse.org/t/working-with-multiple-samples-with-peakvi/1390 "2023-05-05T14:31:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MysoreSparrow](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/mysoresparrow/32/648_2.png) [@MysoreSparrow](https://discourse.scverse.org/u/MysoreSparrow)\
**Post date:** [May 5, 2023, 2:31pm UTC](https://discourse.scverse.org/t/working-with-multiple-samples-with-peakvi/1390/1 "2023-05-05T14:31:27Z")

</div>

Hello scverse community.

I am working with analysis of scATACseq dataset with 5 samples for 5 time points(d01, d05, d10, d25 and an Infected sample). I did the usual pre-processing for each sample (via signac) and I merged these 5 individual samples into a single seurat object :

### atac\_data ← Reduce(function(x, y) merge(x, y), list(d01, d05, d10, d25, Inf\_dpi4)).

This merged object I converted to an anndata object :

### adata ← convertFormat(atac\_data, from = “seurat”, to = “anndata”, main\_layer = “counts”, assay = “peaks”, drop\_single\_values = FALSE, outFile = “converted\_object\_all5\_unfiltered.h5ad”)

and then used it with PEAKVI and obtain the UMAP.

Although I obtained the UMAP for this entire “merged” dataset, I would like to see the sample wise contribution to the UMAP - as an example please see the image below the image from ArchR.

 ![Plot-UMAP-Sample-Clusters-Combined_1](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/24bf61455c974e1576cf12a5b5976ee8c34a66f6.png)

Question 1: Is it correct that I merged the indivodual seurat objects into a single seurat object and then converted it or would it have been better if I had converted 5 seurat objects individually into anndata objects and then concatenated it - Would I then be able access sample-wise information in the UMAP?  
Question2: Is it possible to obtain the sample-wise information for an UMAP obtained from PEAKVI at all or do I need to convert this PEAKVI-trained object back into a seurat object and then try to hopefully generate a UMAP?

I feel like I am missing a step/trick somewhere but I cant see by myself what it is.  
If you could provide me the information and/or point me to a link or tutorial where I can find a solution then it would be very helpful to me. Thank you for your time.

---

<div class="post-metadata">

**Author:** ![martinkim0](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/martinkim0/32/881_2.png) [@martinkim0](https://discourse.scverse.org/u/martinkim0)\
**Post date:** [May 5, 2023, 8:06pm UTC](https://discourse.scverse.org/t/working-with-multiple-samples-with-peakvi/1390/2 "2023-05-05T20:06:08Z")

</div>

Hi, thank you for your question. If you are referring to coloring your UMAP by each experimental sample, I think either of the methods you have listed would work. You would just have to include an observation-wise metadata column indicating which sample each observation originates from.

If you were to convert each seurat object to anndata first, you can just add an `obs` column to each anndata with the sample labels. Then you can pass in that column to your plotting function.

In Python, it might look something like this:

```auto
adata1.obs["sample"] = "d01"
adata2.obs["sample"] = "d05"
# same for other anndatas

adata_all_samples = anndata.concat([adata1, adata2, ...])
sc.pl.umap(adata_all_samples, color="sample")

```
