metbit.univariate.lingress
Other module in metbit 1.0.1.
import metbit.univariate.lingressClasses
lin_regression
This function attempts to fit a model of metabolic profiles by using linear regression
for examples: #set parameter x = Metabolic profiles dataset (dataset X) taget = Metadata of two group (reccomend to sub-class of group label) (dataset Y) Feature_name = name of features of dataset X in this case define to columns name of dataset X
X = spectra_X target = meta['Class'] ppm = spectra_X.columns.astype(float) # columns name of example data is ppm of spectra
test = lin_regression(X, target, ppm)
#Create dataset to do linear regression model
dataset = test.create_dataset() test.show_dataset() # "show_dataset()" function will be return dataset to creat
default methode is "fdr_bh" test.fit_model(dataset, method = "fdr_bh") # fit model with linear regression
- `bonferroni` : one-step correction - `sidak` : one-step correction - `holm-sidak` : step down method using Sidak adjustments - `holm` : step-down method using Bonferroni adjustments - `simes-hochberg` : step-up method (independent) - `hommel` : closed method based on Simes tests (non-negative) - `fdr_bh` : Benjamini/Hochberg (non-negative) - `fdr_by` : Benjamini/Yekutieli (negative) - `fdr_tsbh` : two stage fdr correction (non-negative) - `fdr_tsbky` : two stage fdr correction (non-negative)
# get report can be use .report() function test.report() # "report()" function will be return report dataset as p-value, Beta, R_square, and p-value of F-test in one dataframe
# or u can return each value can be use .p_value(), .beta_value, .r_square, or .f_test()
Methods
__init__(self, x, target, label, features_name)
create_dataset(self)
# Create dataset to do linear regression model # dataset = test.create_dataset() # test.show_dataset() # "show_dataset()" function will be return dataset to creat
show_dataset(self)
fit_model(self, datasets=None, adj_method=None)
# fit model with linear regression
# test.fit_model(dataset, method = "fdr_bh")
# default methode is "fdr_bh" # - `bonferroni` : one-step correction # - `sidak` : one-step correction # - `holm-sidak` : step down method using Sidak adjustments # - `holm` : step-down method using Bonferroni adjustments # - `simes-hochberg` : step-up method (independent) # - `hommel` : closed method based on Simes tests (non-negative) # - `fdr_bh` : Benjamini/Hochberg (non-negative) # - `fdr_by` : Benjamini/Yekutieli (negative) # - `fdr_tsbh` : two stage fdr correction (non-negative) # - `fdr_tsbky` : two stage fdr correction (non-negative)
resampling(self, dataset=None, n_jobs=8, verbose=5, n_boots=50, adj_method=None)
This function performs a resampling of the dataset to calculate the p-value of the log2 fold change and the regression coefficient. The resampling is performed by bootstrapping the dataset. The number of bootstraps is defined by the user. The function returns a dataframe with the p-value and the regression coefficient for each variable. The function also returns a dataframe with the log2 fold change for each variable. The function also returns a dataframe with the q-value for each variable. The function also returns a dataframe with the p-value of the F-test for each variable. The function also returns a dataframe with the q-value of the F-test for each variable.
Parameters
datasetpandas dataframeThe dataset to be analyzed. The dataset must be a pandas dataframe with the first column containing the sample names and the second column containing the group names. The rest of the columns must contain the spectral variables.
n_jobsint, optionalNumber of jobs to run in parallel. The default is 8.
verboseint, optionalVerbosity level. The default is 5.
n_bootsint, optionalNumber of bootstraps. The default is 50.
adj_methodstr, optionalMethod used to adjust the p-value. The default is None. The options are: - None: No adjustment - "bonferroni": one-step correction - "sidak": one-step correction - "holm-sidak": step down method using Sidak adjustments - "holm": step-down method using Bonferroni adjustments - "simes-hochberg": step-up method (independent) - "hommel": closed method based on Simes tests (non-negative) - "fdr_bh": Benjamini/Hochberg (non-negative) - "fdr_by": Benjamini/Yekutieli (negative)
Returns
None.
resampling_df(self, values=None)
# To get the resampling results: resampling_df = test.resampling_df(values='all') print(resampling_df)
save_boostrap(self, path_save, sample_type='No type')
p_value(self)
beta_value(self)
f_test(self)
r_square(self)
q_value(self)
log2_fc(self)
report(self)
# Get report # This will return a report dataset as p-value, Beta, R_square, and p-value of F-test in one dataframe report = test.report() print(report)