LMSstat: Automation of statistical tests with an identical data input
Project description
LMSstat_python: Python implementation of LMSstat (https://github.com/SNUFML/LMSstat)
Installation
pip install lmsstat
Usage
Input format: the first two columns must be Sample (col 0) and Group (col 1). The remaining columns are treated as metabolites/features.
t-test, u-test, ANOVA, and Kruskal-Wallis test
from lmsstat import stat
import pandas as pd
data = pd.read_csv("data.csv")
result = stat.allstats(data)
# result = stat.allstats(data, p_adj=False) # When you don't want to adjust p-value
result.to_csv('result.csv', index=False) # Save the result as a csv file
Normality test
보정되지 않은 결과이므로 주의.
from lmsstat import stat
import pandas as pd
path = "data.csv"
data = pd.read_csv(path)
result = stat.norm_test(data)
result
Data Standardization
import pandas as pd
from lmsstat import stat
path = "data.csv"
data = pd.read_csv(path)
scaled_data = stat.scaling(data)
scaled_data.to_csv("scaled_data.csv")
scaled_data
PCA
from lmsstat import plot
import pandas as pd
data = pd.read_csv("data.csv")
pca_plt = plot.plot_pca(data, n_components=2)
pca_plt[0].show()
print(f"R2: {pca_plt[1]}, Q2: {pca_plt[2]}") # R2, Q2
PLS-DA
from lmsstat import plot
import pandas as pd
data = pd.read_csv("data.csv")
plsda_plt = plot.plot_plsda(data, n_components=2)
plsda_plt[0].show()
print(f"R2X: {plsda_plt[1]}, R2Y: {plsda_plt[2]}, Q2: {plsda_plt[3]}") # R2, Q2
print(plsda_plt[4].head()) # VIP ranking (DataFrame)
Box plot, Bar plot
각각 현재 작업 디렉토리 밑에 만들어진 boxplot, barplot 폴더에 자동으로 저장됨.
from lmsstat import plot, stat
import pandas as pd
data = pd.read_csv("data.csv")
stats_res = stat.allstats(data)
plot.plot_box(data, stats_res, test_type="t-test")
plot.plot_bar(data, stats_res, test_type="t-test")
# plot only significant metabolites for the selected test (default alpha=0.05)
# plot.plot_box(data, stats_res, test_type="t-test", significant_only=True)
# plot.plot_bar(data, stats_res, test_type="t-test", significant_only=True, alpha=0.01)
# limit parallelism (use 1 to run serially)
# plot.plot_box(data, stats_res, test_type="t-test", max_workers=1)
# plot.plot_bar(data, stats_res, test_type="t-test", max_workers=2)
# if your environment shows growing memory usage with long runs, you can restart workers periodically
# plot.plot_box(data, stats_res, test_type="t-test", max_workers=4, restart_every=500)
# boxplot point rendering options
# plot.plot_box(data, stats_res, test_type="t-test", points="none")
# plot.plot_box(data, stats_res, test_type="t-test", points="non_outliers")
Heatmap
from lmsstat import plot
import pandas as pd
data = pd.read_csv("data.csv")
plot.plot_heatmap(data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lmsstat-0.1.1.tar.gz
(978.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
lmsstat-0.1.1-py3-none-any.whl
(24.1 kB
view details)
File details
Details for the file lmsstat-0.1.1.tar.gz.
File metadata
- Download URL: lmsstat-0.1.1.tar.gz
- Upload date:
- Size: 978.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
604faa4bc50dc8622e71417138b25021920fc695bf8bb772bdf4b48a896b1c9f
|
|
| MD5 |
07fd04439cddea075a06a13883363f50
|
|
| BLAKE2b-256 |
e6401e624fa1055c0c5dc3f01686c5f9f0dfc5f27ef5967893375a0876d4e1a1
|
File details
Details for the file lmsstat-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lmsstat-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca5c220eae46c1ce947510445ee7e8ad08163ad64cbb2622900db5d832fa9933
|
|
| MD5 |
96b5ec5c71c47433c14ceab3a6a90829
|
|
| BLAKE2b-256 |
5cab9b858ab8afaba32d2a39fb5ba1a92e61541a3a9700e87741d89865c0edbe
|