Use fast FFT-based mutual information and accelerated gradient method to filter out and optimize nonconvex sparse learning problems on large CSV files or large genetic bed/bim/fam files. Multiprocessing is now available.
Project description
fastHDMI -- fast High-Dimensional Mutual Information
This packages uses mutual information and accelerated gradient method to screen for important variables from (potentially very) high-dimensional large datasets. As a feature, it can be applied on large .csv
data in parallel in a memory-efficient manner and use FFT for KDE to estimate the mutual information extremely fast. It also features screening for SNPs and optimize the nonconvex sparse learning problem on large genetic data using plink files (*.bed/*.bim/*.fam
). The corresponding paper by Yang et al. is coming soon...
The available functions are:
-
continuous_filter_plink
caculates the mutual information between a continuous outcome and a bialletic SNP using FFT. Missing data is acceptable and will be removed. The arguments are:bed_file
,bim_file
,fam_file
are the location of the plink1 files;outcome
,outcome_iid
are the outcome values and the iids for the outcome. For genetic data, it is usual that the order of SNP iid and the outcome iid don't match. While SNP iid can be obtained from the plink1 files, outcome iid here is to be declared separately.outcome_iid
should be a list of strings or a one-dimensional numpy string array.a_min
,a_max
are the minimum and maximum of the continous outcome used to evaluate the support;N=500
is the default values for grid size for FFT.
-
binary_filter_plink
works similarly, execpt thata_min, a_max, N
are not available obviously. -
continuous_filter_plink_parallel
andbinary_filter_plink_parallel
are the multiprocessing version of the above two functions, withcore_num
can be used to declare the number of cores to be used for multiprocessing. -
MI_bivariate_continuous
andMI_binary_continuous
are to calculate mutual information between two continuous variables and binary and continuous variables, respectively.MI_binary_SNP
is ajit
complied function. -
binary_filter_csv
,continuous_filter_csv
,binary_filter_csv_parallel
, andcontinuous_filter_csv_parallel
are to work on large CSV files directly in a memory efficient manner. Note that it is assumed the left first column should be the outcome; if not, use_usecols
to set the first element to be the outcome column label._usecols
is a list of column labels to be used, the first element should be the outcome. Returned mutual information calculation results match_usecols
.Pearson_filter_csv_parallel
calculate Pearson's correlation between only the outcome and the covariates in similiar manner -- sincepandas.DataFrame.corr
calculate pairwise Pearson's correlation for the dataframe.csv_engine
can usedask
for low memory situations, orpandas
'sread_csv
engine
s andfastparquet
engine for a createdparquet
file for faster speed. Iffastparquet
is chosen, declareparquet_file
as the filepath to the parquet file; ifdask
is chosen to read very large CSV, it might be useful to specify a largersample
.
-
UAG_LM_SCAD_MCP
,UAG_logistic_SCAD_MCP
: these functions find a local minizer for the SCAD/MCP penalized linear models/logistic models. The arguments are:design_matrix
: the design matrix input, should be a two-dimensional numpy array;outcome
: the outcome, should be one dimensional numpy array, continuous for linear model, binary for logistic model;beta_0
: starting value; optional, if not declared, it will be calculated based on the Gauss-Markov theory estimators of $\beta$;tol
: tolerance parameter; the tolerance parameter is set to be the uniform norm of two iterations;maxit
: maximum number of iteratios allowed;_lambda
: _lambda value;penalty
: could be"SCAD"
or"MCP"
;a=3.7
,gamma=2
:a
for SCAD andgamma
for MCP; it is recommended fora
to be set as $3.7$;L_convex
: the L-smoothness constant for the convex component, if not declared, it will be calculated by itselfadd_intercept_column
: boolean, should the fucntion add an intercept column?
-
solution_path_LM
,solution_path_logistic
: calculate the solution path for linear/logistic models; the only difference from above is thatlambda_
is now a one-dimensional numpy array for the values of $\lambda$ to be used. -
UAG_LM_SCAD_MCP_strongrule
,UAG_logistic_SCAD_MCP_strongrule
work just likeUAG_LM_SCAD_MCP
,UAG_logistic_SCAD_MCP
-- except they use strong rule to filter out many covariates before carrying out the optimization step. Same forsolution_path_LM_strongrule
andsolution_path_logistic_strongrule
. Strong rule increases the computational speed dramatically. -
SNP_UAG_LM_SCAD_MCP
andSNP_UAG_logistic_SCAD_MCP
work similar toUAG_LM_SCAD_MCP
andUAG_logistic_SCAD_MCP
; andSNP_solution_path_LM
andSNP_solution_path_logistic
work similar tosolution_path_LM
,solution_path_logistic
-- except that it takes plink1 files so it will be more memory-efficient. Since PCA adjustment is usually used to adjust for population structure, PCA can be given forpca
as a 2-d array -- each column should be one principal component. The pca version isSNP_UAG_LM_SCAD_MCP_PCA
andSNP_UAG_logistic_SCAD_MCP_PCA
.
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
Built Distribution
Hashes for fastHDMI-1.16.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5d8f5f306c4244e4f7db03dc625652d73f7f1d29abe6aa9bd01ea4b79f422e1 |
|
MD5 | 296b69ec24f4d5fab31c07bd75225a7f |
|
BLAKE2b-256 | bac4d5514de3c739161311e8753f4b937a884bd303eadbc9c068b4dc944b5a81 |