# SOLO usage - batch, training, predicting

**URL:** https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60
**Category:** scvi-tools
**Created:** [March 25, 2021, 5:46pm UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60 "2021-03-25T17:46:24Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![bjstewart1](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/bjstewart1/32/30_2.png) [@bjstewart1](https://discourse.scverse.org/u/bjstewart1)
#### Post date: [March 25, 2021, 5:46pm UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/1 "2021-03-25T17:46:24Z")

</div>

Hello - great set of tools, extremely useful.

I was hoping to try using SOLO for doublet detection and can see this is now incorporated into scvi tools.  
I’m not finding the usage of this particularly clear.  
Seems that the guidance is that it should be run on a single droplet sequencing lane at a time, and it’s not possible to run after training an scvi model with batch correction. Is that correct?

After training then predicting I am getting a numpy array which is a little difficult to interpret - the dimensions are larger than the original anndata object - so perhaps it is the simulated doublets and the native cells together. It’s just a little unclear.  
Any chance you could clarify how best to use this tool?

Thanks,

---

<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: [March 25, 2021, 11:54pm UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/2 "2021-03-25T23:54:07Z")

</div>

Thank you for the raising this. Indeed it looks like the `predict()` method will give predictions of real cells and simulated doublets.

> [@bjstewart1](#):
>
> Seems that the guidance is that it should be run on a single droplet sequencing lane at a time, and it’s not possible to run after training an scvi model with batch correction. Is that correct?

Indeed this is true; this is how Solo was designed, as doublets are generated within a specific lane.

> [@bjstewart1](#):
>
> Any chance you could clarify how best to use this tool?

The workflow in the examples of the documentation should be followed, except here is a workaround to process the output of the predict function.

```python
def process_predict_output(output, solo_model):
    import pandas as pd
    label = solo_model.adata.obs["_solo_doub_sim"].values.ravel()
    preds = output[label == "singlet"]
    cols = solo_model.adata.uns["_scvi"]["categorical_mappings"]["_scvi_labels"]["mapping"]
    preds_df = pd.DataFrame(preds, columns=cols)
    return preds_df

```

This will give you the predictions with same order as the input anndata, and now named columns of the prediction, if you ran `solo.predict(soft=True)`.

We will update the code so this is more straightforward.

---

<div class="post-metadata">

### Author: ![bjstewart1](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/bjstewart1/32/30_2.png) [@bjstewart1](https://discourse.scverse.org/u/bjstewart1)
#### Post date: [March 26, 2021, 9:31am UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/3 "2021-03-26T09:31:11Z")

</div>

Thanks for your quick and helpful response Adam.  
I’m just conscious that with multiple droplet lanes, this requires recomputing a model for each lane which would be very time consuming for big experiments.  
I wonder if it would be possible to compute a model overall for the experiment and then run solo off that for subsets corresponding to individual lanes? Or do you think this would break some important assumptions of the tool?

---

<div class="post-metadata">

### Author: ![davek44](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/davek44/32/33_2.png) [@davek44](https://discourse.scverse.org/u/davek44)
#### Post date: [March 28, 2021, 1:34am UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/4 "2021-03-28T01:34:55Z")

</div>

Yes, it’s totally fine to fit one scVI model and then run Solo independently for each lane, seeded from that model. That --seed option in our CLI demonstrates that workflow: [solo/solo.py at master · calico/solo · GitHub](https://github.com/calico/solo/blob/master/solo/solo.py#L202)

---

<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: [March 28, 2021, 4:28pm UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/5 "2021-03-28T16:28:37Z")

</div>

> [@davek44](#):
>
> Yes, it’s totally fine to fit one scVI model and then run Solo independently for each lane

Hmmm I think we might need to change the scvi-tools Solo API a bit to allow this. I can do this relatively soon.

---

<div class="post-metadata">

### Author: ![bjstewart1](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/bjstewart1/32/30_2.png) [@bjstewart1](https://discourse.scverse.org/u/bjstewart1)
#### Post date: [March 28, 2021, 5:04pm UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/6 "2021-03-28T17:04:53Z")

</div>

Thanks for your thoughts on this @davek44 & @adamgayoso  
I think modifying the API to allow for this approach would be extremely useful

---

<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: [March 28, 2021, 5:49pm UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/7 "2021-03-28T17:49:08Z")

</div>

[PR](https://github.com/YosefLab/scvi-tools/pull/1009) is up.

---

<div class="post-metadata">

### Author: ![malonzm1](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@malonzm1](https://discourse.scverse.org/u/malonzm1)
#### Post date: [May 8, 2024, 12:39am UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/8 "2024-05-08T00:39:57Z")

</div>

Hi,

I used `scvi.external.SOLO.from_scvi_model`. How do I find `output` and `solo_model`?

Thanks.

---

<div class="post-metadata">

### Author: ![malonzm1](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@malonzm1](https://discourse.scverse.org/u/malonzm1)
#### Post date: [May 8, 2024, 2:16am UTC](https://discourse.scverse.org/t/solo-usage-batch-training-predicting/60/9 "2024-05-08T02:16:24Z")

</div>

This is resolved. Thanks.
