### Column Selection Syntax Examples Source: https://context7.com/idinsmore1/polars-mas/llms.txt Demonstrates flexible column specification using names, zero-based indices, ranges, and mixed formats for input, dependent variables, and covariates. ```bash # By column names (comma-separated) polars-mas -i data.csv -o out -p snp1,snp2 -d phenotype -c age,sex # By index (0-based) polars-mas -i data.csv -o out -p i:0 -d i:5 -c i:1-4 # Column 10 only -d i:10 # Columns 10 through 19 (exclusive end) -d i:10-20 # Column 10 to end of file -d i:10- # Mixed: names and indices together -c age,sex,i:8-12 ``` -------------------------------- ### Install polars-mas using pip Source: https://context7.com/idinsmore1/polars-mas/llms.txt Installs the polars-mas library using pip. This is the standard method for installing Python packages. ```bash pip install polars-mas ``` -------------------------------- ### Install polars-mas using uv Source: https://context7.com/idinsmore1/polars-mas/llms.txt Installs the polars-mas library using uv, a fast Python package installer and resolver. This is an alternative to pip. ```bash uv add polars-mas ``` -------------------------------- ### Column Selection by Name and Index in polars-mas Source: https://github.com/idinsmore1/polars-mas/blob/main/README.md Examples of how to specify columns for predictors, dependents, and covariates in the polars-mas CLI. Columns can be selected by their names or by their 0-based index, including ranges. ```bash # By name in comma-separated list -p age,sex,bmi # By index (0-based) -d i:10 # Column 10 -d i:10-20 # Columns 10-19 -d i:10- # Column 10 to end # Can be used in conjuction as well! -c age,sex,i:8-12 ``` -------------------------------- ### Configure Threading for Performance (CLI) Source: https://context7.com/idinsmore1/polars-mas/llms.txt Configure threading for optimal performance on your system. This example uses 8 computation threads, recommended to match available cores. The '-t' flag controls threading, while '-n' is reserved for future use. ```bash # Use 8 computation threads (recommended: match available cores) polars-mas \ -i large_data.parquet \ -o results \ -p exposure \ -d i:10-2000 \ -c age,sex,pc1,pc2,pc3,pc4,pc5 \ -t 8 # Note: -n (num-workers) is reserved for future parallel processing # Currently, use -t for threading. More threads = faster for large analyses # Memory optimization: Uses /dev/shm on Linux when >2GB available # Falls back to temp directory automatically if insufficient space ``` -------------------------------- ### Reproducing Benchmarks with Bash and R Source: https://github.com/idinsmore1/polars-mas/blob/main/benchmarks/README.md This snippet outlines the steps to reproduce the benchmarks using R scripts for data generation and bash scripts for running performance tests. It also includes instructions for generating plots using a Jupyter notebook. ```bash # Generate example datasets Rscript generate_examples.R # Run sample size scaling benchmarks ./run_benchmarks.sh # Run covariate scaling benchmarks ./run_covariate_scaling_benchmarks.sh # Generate plots jupyter notebook benchmark_plotting.ipynb ``` -------------------------------- ### Basic polars-mas CLI Usage Source: https://github.com/idinsmore1/polars-mas/blob/main/README.md This command demonstrates basic usage of the polars-mas command-line interface. It specifies input and output files, predictor, dependent variables (by column index range), and covariates. ```bash polars-mas \ -i data.csv \ -o results \ -p exposure \ -d i:10- \ -c age,sex,bmi ``` -------------------------------- ### Run PheWAS Analysis and Understand Output Schema (CLI) Source: https://context7.com/idinsmore1/polars-mas/llms.txt This command runs a PheWAS analysis and details the output columns for logistic and linear models. For logistic models, it includes p-value, beta, odds ratio, confidence intervals, case/control counts, and convergence status. Linear models add total observations and omit the odds ratio. ```bash # Run analysis polars-mas -i data.csv -o results -p snp -d i:10-100 -c age,sex --phewas # Output columns for logistic models (firth, logistic): # predictor - Predictor variable name # dependent - Dependent variable (phecode) name # pval - P-value (likelihood ratio test for Firth) # beta - Log-odds coefficient estimate # se - Standard error of beta # OR - Odds ratio (exp(beta)) # ci_low - Lower 95% confidence interval for OR # ci_high - Upper 95% confidence interval for OR # cases - Number of cases (dependent=1) # controls - Number of controls (dependent=0) # total_n - Total sample size after dropping nulls # converged - Model convergence status (boolean) # bonferroni_significant - Passed Bonferroni correction (boolean) # phenotype - PheCode description (with --phewas) # category - PheCode category (with --phewas) # equation - Full regression equation used # failed_reason - Reason if analysis failed (e.g., insufficient cases) # Output columns for linear models add: # n_observations - Total observations (replaces cases/controls) # Note: OR is not included for linear regression ``` -------------------------------- ### Configure Output File Format (CLI) Source: https://context7.com/idinsmore1/polars-mas/llms.txt Control the output file format and verbosity of the polars-mas tool. Options include parquet, csv, and tsv for output type, and flags for verbose (-v) or quiet (-q) logging, and dry run (--dry-run). ```bash # Output as Parquet (most efficient for large results) polars-mas -i data.parquet -o results -p exp -d i:10- -c age -ot parquet # Output as CSV (default) polars-mas -i data.csv -o results -p exp -d i:10- -c age -ot csv # Output as TSV or TXT (tab-delimited) polars-mas -i data.csv -o results -p exp -d i:10- -c age -ot tsv # Verbose logging for debugging polars-mas -i data.csv -o results -p exp -d i:10- -c age -v # Quiet mode (minimal output) polars-mas -i data.csv -o results -p exp -d i:10- -c age -q # Dry run - show configuration without running analysis polars-mas -i data.csv -o results -p exp -d i:10- -c age --dry-run ``` -------------------------------- ### Categorical Covariates Handling Source: https://context7.com/idinsmore1/polars-mas/llms.txt Automatically generates dummy variables for categorical covariates that have more than two levels, simplifying their inclusion in regression models. ```bash # Example demonstrating categorical covariate handling would go here, but is not provided in the input text. ``` -------------------------------- ### PheWAS Analysis with polars-mas CLI Source: https://github.com/idinsmore1/polars-mas/blob/main/README.md This command performs a PheWAS analysis using the polars-mas CLI. It includes options for automatic PheCode annotation, number of workers, and threads per worker. ```bash polars-mas \ -i phewas_data.parquet \ -o phewas_results \ -p genetic_variant \ -d i:20-1850 \ -c age,sex,pc1,pc2,pc3 \ --phewas \ -n 4 \ -t 8 ``` -------------------------------- ### Sex-Specific Analysis CLI Source: https://context7.com/idinsmore1/polars-mas/llms.txt Enables filtering of samples by sex for sex-specific phenotype analysis. Options include male-only analysis or female-only analysis, with configurable sex column names and female codes. ```bash # Male-only analysis polars-mas \ -i data.csv \ -o male_results \ -p exposure \ -d i:10- \ -c age,bmi \ --sex-col sex \ --male-only # Female-only analysis (default female code is 1) polars-mas \ -i data.csv \ -o female_results \ -p exposure \ -d i:10- \ -c age,bmi \ --sex-col gender \ --female-code 2 \ --female-only ``` -------------------------------- ### Specify Categorical Covariates for Dummy Encoding (CLI) Source: https://context7.com/idinsmore1/polars-mas/llms.txt This command specifies categorical covariates for automatic dummy encoding. 'race' and 'education' will be expanded to dummy variables, with the first level dropped to avoid multicollinearity. Continuous covariates like 'age' and 'sex' remain unchanged. ```bash polars-mas \ -i data.csv \ -o out \ -p exposure \ -d i:10- \ -c age,sex,race,education \ -cc race,education ``` -------------------------------- ### Basic Association Analysis CLI Source: https://context7.com/idinsmore1/polars-mas/llms.txt Performs multiple association tests with a single predictor against multiple dependent variables, controlling for specified covariates. The output includes p-value, beta, standard error, odds ratio, confidence intervals, case/control counts, and convergence status. ```bash # Basic usage: Test 'exposure' against columns 10 onwards, controlling for age, sex, bmi polars-mas \ -i data.csv \ -o results \ -p exposure \ -d i:10- \ -c age,sex,bmi # Output: results_polars_mas_results.csv with columns: # predictor, dependent, pval, beta, se, OR, ci_low, ci_high, cases, controls, converged, bonferroni_significant ``` -------------------------------- ### FlipWAS Analysis CLI Source: https://context7.com/idinsmore1/polars-mas/llms.txt Performs a reverse PheWAS where phecodes act as predictors and a quantitative trait is the outcome. This analysis uses linear regression and automatically adds PheCode annotations to the results. ```bash # FlipWAS: Test each phecode (predictors) against a quantitative outcome polars-mas \ -i flipwas_data.csv \ -o flipwas_results \ -p i:5-1800 \ -d bmi \ -c age,sex \ --flipwas \ -m linear \ --quantitative \ -t 4 # Uses linear regression for quantitative outcomes # PheCode annotations added based on predictor columns ``` -------------------------------- ### Missing Covariate Handling Options Source: https://context7.com/idinsmore1/polars-mas/llms.txt Configures how missing values in covariates are managed, including failing the analysis, dropping rows, or imputing with various strategies like mean, zero, or forward/backward fill. ```bash # Fail if any missing values (default - safest) polars-mas -i data.csv -o out -p exp -d i:10- -c age,sex -mcv fail # Drop rows with missing covariate values polars-mas -i data.csv -o out -p exp -d i:10- -c age,sex -mcv drop # Impute with mean values polars-mas -i data.csv -o out -p exp -d i:10- -c age,sex -mcv mean # Other imputation options: forward, backward, min, max, zero, one polars-mas -i data.csv -o out -p exp -d i:10- -c age,sex -mcv zero # Specify null value strings in input data polars-mas -i data.csv -o out -p exp -d i:10- -c age,sex -nv "NA,.,missing" ``` -------------------------------- ### Regression Model Selection Source: https://context7.com/idinsmore1/polars-mas/llms.txt Allows selection of different regression models: Firth logistic (default, for rare events), standard logistic (for balanced binary outcomes), and linear (for continuous outcomes). ```bash # Firth logistic regression (default) - handles rare events and separation polars-mas -i data.csv -o out -p exposure -d i:10- -c age,sex -m firth # Standard logistic regression - faster, for balanced binary outcomes polars-mas -i data.csv -o out -p exposure -d i:10- -c age,sex -m logistic # Linear regression - for continuous/quantitative outcomes polars-mas -i data.csv -o out -p exposure -d outcome -c age,sex -m linear --quantitative # Minimum case/control count (default 20, applies to both cases AND controls) polars-mas -i data.csv -o out -p exposure -d i:10- -c age,sex -mc 50 ``` -------------------------------- ### PheWAS Analysis CLI Source: https://context7.com/idinsmore1/polars-mas/llms.txt Conducts a phenome-wide association study, automatically annotating results with PheCode names and categories. It supports multi-threading for faster analysis and is suitable for testing genetic variants against numerous phenotypes. ```bash # PheWAS: Test genetic_variant against 1830 phecodes (columns 20-1850) # with 5 covariates, using 8 threads polars-mas \ -i phewas_data.parquet \ -o phewas_results \ -p genetic_variant \ -d i:20-1850 \ -c age,sex,pc1,pc2,pc3 \ --phewas \ -t 8 # Output includes phenotype names and categories from built-in PheCode definitions # Results sorted by p-value for easy identification of significant associations ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.