# Extracting Probability of Observation Matrix

**URL:** <https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90>\
**Category:** scvi-tools\
**Tags:** peakvi\
**Created:** [May 10, 2021, 4:55pm UTC](https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90 "2021-05-10T16:55:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iluthra](https://avatars.discourse-cdn.com/v4/letter/i/e36b37/32.png) [@iluthra](https://discourse.scverse.org/u/iluthra)\
**Post date:** [May 10, 2021, 4:55pm UTC](https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90/1 "2021-05-10T16:55:54Z")

</div>

Hi!

I am trying to extract the Probability of observation matrix (regions by cells) from a trained model. Is this automatically saved in the AnnData object?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![Tal\_Ashuach](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/tal_ashuach/32/48_2.png) [@Tal\_Ashuach](https://discourse.scverse.org/u/Tal_Ashuach)\
**Post date:** [May 10, 2021, 10:51pm UTC](https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90/2 "2021-05-10T22:51:16Z")

</div>

Hi!

We don’t generate or save it by default, but you can generate it using:  
`model.get_accessibility_estimates(adata)`.

Some notes on using it:  
1 - do you want the estimated probability of _accessibility_ or the probability of _observation_? This method by default gives the former (i.e after removing cell-specific and region-specific biases).  
If you want the probability of _observation_, you’ll want to re-introduce those biases by setting `normalize_cells=True, normalize_regions=True`.  
2 - the output can be quite large (since the matrix is dense). You can shrink the size by only generating the estimates for some cells / some regions (using the `indices` and `region_indices` arguments, respectively); alternatively, you can threshold the output so that estimates below some given threshold are replaced with 0s, and the output matrix is sparse.

---

<div class="post-metadata">

**Author:** ![iluthra](https://avatars.discourse-cdn.com/v4/letter/i/e36b37/32.png) [@iluthra](https://discourse.scverse.org/u/iluthra)\
**Post date:** [May 11, 2021, 8:42pm UTC](https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90/3 "2021-05-11T20:42:20Z")

</div>

Thank you for the detailed response! Very helpful 🙂

---

<div class="post-metadata">

**Author:** ![vitkl](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/vitkl/32/169_2.png) [@vitkl](https://discourse.scverse.org/u/vitkl)\
**Post date:** [September 15, 2022, 3:04pm UTC](https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90/4 "2022-09-15T15:04:20Z")

</div>

Hi @Tal_Ashuach @adamgayoso

 ![Screenshot 2022-09-04 at 15.38.48](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/41615344c1c207b4a5bbc9db5e2a0b89c5b9b207.jpeg)

1. Just to clarify further, `.get_accessibility_estimates(adata)` by default  
returns `y_ij` and with `.get_accessibility_estimates(adata, normalize_cells=True, normalize_regions=True)` you get `y_ij * l_i * r_j` ?

2. Can the `adata` be different to the `adata` used for training given that the object contains all the same columns/slots? I would like to compute accessibility estimates for cells not seen during traning.

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [September 17, 2022, 10:40pm UTC](https://discourse.scverse.org/t/extracting-probability-of-observation-matrix/90/5 "2022-09-17T22:40:19Z")

</div>

> [@vitkl](#):
>
> Just to clarify further, `.get_accessibility_estimates(adata)` by default  
> returns `y_ij` and with `.get_accessibility_estimates(adata, normalize_cells=True, normalize_regions=True)` you get `y_ij * l_i * r_j` ?

Yes

> [@vitkl](#):
>
> Can the `adata` be different to the `adata` used for training given that the object contains all the same columns/slots? I would like to compute accessibility estimates for cells not seen during traning.

Yes, we have an extensive validation procedure that will flag any inconsistencies in the new data.
