Understanding `differential_expression()` and lvm-DE

I are interested in looking code behind the differential_expression() function, in particular the lvm-DE method. From an issue in scVI-tools Github, it seems as though the lvm-DE method is now a part of the general differential_expression() function in ‘scVI-tools’ (when using weights=“importance”).

Exploring scVI-tools, it seems like the differential_expression() function code is tied to _de_core.py and _differential.py (same folder as _de_core.py; can’t add a third link). However, I can’t find the “weights” flag in either script (or a conditional looking for the word “importance”), which makes me think I’m looking in the wrong spot.

Any help to direct me would be most appreciated.

Hi, lvmDE is active when using mode=‘change’ (the default), while the old method requires mode=‘vanilla’. Weights=‘importance’ changes the manner samples are taken in get_normalized_expression.

1 Like

Thanks for your reply. I had a hard time understanding what combination of settings constituted the lvm-DE method. The guide really didn’t go over that.

de_results = model.differential_expression( groupby="subtype", idx1=group1, idx2=group2, weights="importance", batch_correction=False, delta=None, fdr_target=0.01 )

Can you help me understand where “differential_expression()” and “get_normalized_expression()” interact? Adding “weights=importance” to “differential_expression” clearly makes a big impact on the results, but I can’t seem to figure out how adding the “weights” flag to the former function calls the latter.

scvi-tools/scvi/model/base/_rnamixin.py at d094c9b3c14e8cb3ac3a309b9cf0160aff237393 · scverse/scvi-tools · GitHub defines a partial function of get_normalized_expression.

1 Like