-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add basic LMM analysis example (#55)
- Loading branch information
1 parent
4481a8f
commit d2589d2
Showing
10 changed files
with
169 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,3 +107,4 @@ _version_save.py | |
docs/*.bib.bak | ||
.idea | ||
build-recipes/ShapeOut2Launcher.spec | ||
.Rhistory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""Screenshots for quick guide R-lme4""" | ||
import pathlib | ||
import sys | ||
|
||
from PyQt5 import QtCore | ||
from PyQt5.QtWidgets import QApplication | ||
from shapeout2.gui.main import ShapeOut2 | ||
from shapeout2.gui import compute | ||
|
||
test_data = pathlib.Path(__file__).parent / ".." / ".." / "tests" / "data" | ||
|
||
|
||
app = QApplication(sys.argv) | ||
|
||
QtCore.QLocale.setDefault(QtCore.QLocale(QtCore.QLocale.C)) | ||
|
||
mw = ShapeOut2() | ||
mw.settings.setValue("check for updates", 0) | ||
mw.settings.setValue("advanced/check pyqtgraph version", 0) | ||
|
||
# build up a session | ||
mw.on_action_open(test_data / "version_2_5_0_dcor_lme4.so2") | ||
|
||
# create dialog manually | ||
dlg = compute.ComputeSignificance(mw, pipeline=mw.pipeline) | ||
|
||
# set the variables | ||
# treatment rep 1 | ||
dlg.datasets[0].comboBox_group.setCurrentIndex(1) | ||
# treatment rep 2 | ||
dlg.datasets[1].comboBox_group.setCurrentIndex(1) | ||
dlg.datasets[0].spinBox_repeat.setValue(2) | ||
# control rep 1 | ||
pass | ||
# control rep 2 | ||
dlg.datasets[3].spinBox_repeat.setValue(2) | ||
# control rep 3 | ||
dlg.datasets[4].spinBox_repeat.setValue(3) | ||
|
||
# set the feature | ||
feat_id = dlg.comboBox_feat.findData("deform") | ||
dlg.comboBox_feat.setCurrentIndex(feat_id) | ||
|
||
dlg.show() | ||
QApplication.processEvents() | ||
dlg.grab().save("_qg_lme4_init.png") | ||
|
||
dlgr = dlg.on_lme4(ret_dlg=True) | ||
dlgr.show() | ||
QApplication.processEvents() | ||
dlgr.grab().save("_qg_lme4_results.png") | ||
|
||
mw.close() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.. _sec_qg_lme4: | ||
|
||
============================================= | ||
Statistical significance testing (R and lme4) | ||
============================================= | ||
Since version 2.5.0, Shape-Out 2 allows you to quantify the statistical | ||
significance (p-value) when comparing two measurement groups. The analysis | ||
uses linear mixed effects models (LMM) as described in :cite:`Herbig2018` | ||
and yields results identical to those obtained with Shape-Out 1. | ||
|
||
The LMM analysis is performed using the lme4 R package | ||
and is based on the :ref:`implementation in dclab <dclab:sec_av_lme4>` | ||
(please read for more information on the options available) which uses | ||
`rpy2 <https://github.com/rpy2/rpy2/>`_ to connect to R. | ||
Here, we make use of the dataset :cite:`FigshareLMM` to illustrate this | ||
functionality. | ||
|
||
|
||
Basic linear mixed models | ||
------------------------- | ||
We would like to quantify the difference between human skeletal stem cells | ||
(SSC) and the human osteosarcoma cell line MG-63 (which is often used as a | ||
model system for SSCs) using a likelihood ratio test based on LMM. | ||
|
||
Please load :download:`this session <../tests/data/version_2_5_0_dcor_lme4.so2>` | ||
into Shape-Out (via *File | Open Session*). The experimental data are accessed | ||
from DCOR, so you will need a working internet connection. The session contains | ||
five datasets: | ||
|
||
- SSC_16uls_rep1_20150611.rtdc (SSC repetition 1) | ||
- SSC_16uls_rep2_20150611.rtdc (SSC repetition 2) | ||
- MG63_pure_16uls_rep1_20150421.rtdc (MG-63 repetition 1) | ||
- MG63_pure_16uls_rep2_20150422.rtdc (MG-63 repetition 2) | ||
- MG63_pure_16uls_rep3_20150422.rtdc (MG-63 repetition 3) | ||
|
||
In this example, we treat SSC as our "treatment" and MG-63 as our "control". | ||
These are just group names that remind us that we are comparing one type of | ||
sample against another type. | ||
|
||
Note that the settings for Young's modulus computation have already been | ||
defined and that the datasets are already filtered with these box filters: | ||
|
||
- Porosity (*area_ratio*): 0 to 1.05 | ||
- Area [µm²] (*area_um*): 120 to 550 | ||
- Deformation (*deform*): 0 to 0.1 | ||
|
||
To perform an LMM analysis, go to *Compute | Statistical significance* and | ||
set the groups (SSC: treatment; MG63: control) and repetitions (enumeration | ||
by date-time). | ||
|
||
.. image:: scrots/qg_lme4_init.png | ||
:target: _images/qg_lme4_init.png | ||
|
||
Make sure that the feature "Deformation" is selected and hit *Run R-lme4*. The | ||
results of the LMM analysis are shown in a new dialog. | ||
|
||
.. image:: scrots/qg_lme4_results.png | ||
:target: _images/qg_lme4_results.png | ||
|
||
The most important numbers are extracted from the report and are shown at | ||
the top: | ||
|
||
- **Fixed effect intercept:** | ||
The mean of the parameter chosen for all controls. | ||
|
||
- **Fixed effect treatment:** | ||
The effect size of the parameter chosen between the mean | ||
of all controls and the mean of all treatments. | ||
|
||
- **Anova p-value:** | ||
The p-value of the ANOVA test. | ||
|
||
In the report, you will also find the **Full coefficient table**, which | ||
shows the effect size of the parameter chosen between control and treatment | ||
for every single experiment. | ||
|
||
We are interested in the p-value, which is 0.01256 for | ||
Deformation. We repeat the analysis with Area (0.0002183) and Young's | ||
modulus (0.0002777). The p-values indicate that MG-63 (mean elastic | ||
modulus 1.26 kPa) cells are softer than SSCs (mean elastic modulus 1.54 kPa) | ||
:cite:`Herbig2018`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ Quick Guides | |
sec_qg_filtering | ||
sec_qg_dcor | ||
sec_qg_youngs_modulus | ||
sec_qg_lme4 | ||
sec_qg_batch_stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters