pachterlab / sleuth

Differential analysis of RNA-Seq
http://pachterlab.github.io/sleuth
GNU General Public License v3.0
305 stars 95 forks source link

model ift #263

Closed polarbearsmall closed 2 years ago

polarbearsmall commented 2 years ago

Dear guys,

After sleuth fit, I found that there is one treatIgG4 lost, which can not be used in which_beta. Following the walkthrough, while treatControl can be choosed in which_beta ; so is the heatmap can be used to show the differential expression among the treatments?

If I change the which_beta to treatIgG1.. treatIgG4, I would get four different heatmaps, then which one to use, and how to interpret the heatmap?

Thank you very much!

so <- sleuth_fit(so, ~treat, 'full') ## expect to compare Control, IgG1, IgG2, IgG3, IgG4, so <- sleuth_fit(so, ~1, 'reduced') so <- sleuth_lrt(so, 'reduced', 'full')

oe <- sleuth_wt(so, which_beta='treatIG1')

mschilli87 commented 2 years ago

@polarbearsmall: Not sure if I understood your problem completely but to me it sounds like you are using a categorical parameter in you model. For the simplest case, consider a binary variable like case vs. control, wild type vs. mutant or sex (male vs. female). The way to encode these for linear models is usually by defining one state (the 'reference') as zero and the other as one. This way, all samples share the entire equation but the beta corresponding to sex is multiplied by zero for females and one for males. So it quantifies the difference between males and females. In the case of case vs. control or mutant vs. wild type there is a 'logical' choice for the reference, for others (like sex) you have to choose arbitrarily. So I think the condition you are lacking is simply your reference one which you cannot compare to itself, so you don't have a beta. Note that when you have more than two categories, one beta is used comparing each non-reference to the reference. IIRC sleuth uses factors for this so by default the options will be sorted alphabetically and the smallest one ends up being used as reference. As for the interpretation, it kinda depends on your model and what your are trying to ask but note that this has nothing to do with sleuth specifically and should probably discussed elsewhere.

I hope this helps you to figure out your problem. If so, don't forget to close the issue and maybe share your solution for others running into similar issues.

polarbearsmall commented 2 years ago

Thanks a lot!

Wish can allow more time to figure out the issue, for the samples, it comes from patients of different districts, and the treatment used several different antibody. So the compare can be the district and also the antibody, at the fist time, I ignored the district, and only set design ~ treatment.

For the beta, if the default options is to sort alphabetically and the smallest one as reference, is it possible to change use based on the treatment name? As from the annotation file, I know the one labels control.

mschilli87 commented 2 years ago

If you want to change the reference, make sure your treatment color in the input table is a factor with the correct value as first level. Have a look at forcats::fct_relevel for a convenient way to do so.