A small Python package to aid morphometric analysis. Automates allometric correction and principal component analysis.
Table of Contents
morphostuff can be installed using pip like so:
python3 -m pip install morphostuff
You should also install the required dependencies:
python3 -m pip install polars scikit-learn seaborn
You can import morphostuff into a Python script like so:
import morphostuff as mstuff
Ensure your data are in the proper format. The first column (index 0) should consist of the species name or other identifying information. The second column (index 1) should consist of a standard body length measurement such as SVL. The following columns (indices 2:) should consist of other measurements.
The allom function only requires a data frame as input. A Polars data frame is recommended, but it can also take a Pandas data frame as input. Example:
morph_data = pl.read_csv('morph_data.csv')
allom_data = mstuff.allom(morph_data)
This function outputs a table of allometrically corrected features.
Use help(mstuff.allom)
for more information.
The input of this function should be a data frame of allometrically corrected
characters (i.e., the output of allom
). It should follow the same structure
as the allom
inputs.
morpho_data = mstuff.morph_pca(allom_data)
This function outputs a table containing allometric size corrections, a table containing PCA results, and a PCA biplot.
Use help(mstuff.morph_pca)
for more information.
This function will determine how many principal components account for at least 90% of explained variance and which characters weigh heavily on each PC according to the following formula:
The input of this function should be the data frame generated as output of
morph_pca
.
significant_features = mstuff.significant_features(morpho_data)
This function outputs a scree plot, barplots for each PC, a table of loadings of the significant PCS, and a table of significance of each character by PC. These outputs are all written to the disk.
Use help(mstuff.significant_features)
for more information.
morphostuff uses the following technologies and tools:
To contribute to the development of morphostuff, follow the steps below:
- Fork morphostuff from https://github.com/holsfastagz/morphostuff/fork
- Create your feature branch (
git checkout -b feature-new
) - Make your changes
- Commit your changes (
git commit -am 'Add some new feature'
) - Push to the branch (
git push origin feature-new
) - Create a new pull request
Holsen B. Moore - @h0ls.bsky.social - holsenmoore@utexas.edu
- 0.1
- First working version.
morphostuff is distributed under the MIT license. See LICENSE
for more details.