BetaNegBinFit
A very brief manual
The cornerstones (or rather, to be more precise, parts that are supposed to be used by a user, rather than a developer) of BetaNegBinFit are model classes that do model certain distribution and do some heavy lifting. At the moment, there are 2 models available:
ModelMixture-- a model that models counts at a certain slice as a mixture of 2 binomial-alike distributions;ModelLine-- this can be thought of as a composition of a lot ofModelMixtures (their number is equal to a number of slices), but they are linked via constraining r parameter to a linear function of slice.
Both models can use either negative-binomial or beta-negative-binomial distribution (see model argument of their __init__ methods).
Use example: *ModelMixture"
Running ModelMixture is as simple as:
from betanegbinfit import ModelMixture
m = ModelMixture(bad=2, left=4)
res = m.fit(some_slice)
Then, you can inspect parameters through examining the res variable which is a fairly self-explanotory dict.
Some_slice?
Assume that we want to get slice of refs with fix__c = 23 for BAD=3 for our chipseq-dataset, some_slice. We suggest doing it this way:
data_folder = 'Data'
data_file = os.path.join(data_folder, 'chipseq.tsv')
bad = 3
fix_c = 23
dfo = pd.read_csv(data_file, sep='\t')
dfo = dfo[dfo.BAD == bad]
refs = dfo.REF_COUNTS
alts = dfo.ALT_COUNTS
some_slice = refs[alts == c]
Use example: ModelLine
ModelLine is ran similarly, but this time we pass whole data to the fit method instead of a single slice:
from betanegbinfit import ModelLine
m = ModelLine(bad=2, left=4)
res = m.fit(data)
We advise that data is a n x 2 numpy array rather than pandas DataFrame (where the 1st column stands for reference allele counts and the 2nd for alt counts), however if that is not the case, ModelLine will try to guess ref count, alt count and BAD columns from the dataframe.
Statistics
stats module has a number of functions that can be of interest to a prospective user:
rmsea- calculate RMSEA goodness-of-fit statistic;calc_pvalues- calculate p-value for each of snp;calc_eff_sizes- calculate "effect sizes" for each of snp;calc_adjusted_loglik- calcualte adjusted loglikelihood: adjusted loglikelihood is just a likelihood correct for its parameters geometry. It is done vis subtracting logdet of Fisher information matrix.
Automatic everything & multiprocessing
However, instead of manually creating instances of model classes and working through BetaNegBinFit methods, it might be much more preferential to run a single to-use function. The package has utils.run function that is very easy to use and also does parallelization. See test.py for a real (and a very short one) example. Most importantly, it produces tabular data that can be easily analyzed in a downstream analysis.
Also, it has plenty of arguments that can be taked advantage of to do some preprocessing which might be crucial for some datasets.
Please note, that all functions have plenty of optional arguments and they all are documented, so please consider reading through help(function of interest).
A note on performance
As far as we are concerned, BetaNegBinFit should work within a manageable amounts of time. For insance, when ModelLine with model='BetaNB' ran against chipseq.tsv dataset, it finishes in 6 minutes when ran at Ryzen 5600U. It does so under 2 minutes with model='NB'.
Metadata
Release files for betanegbinfit 1.10.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| betanegbinfit-1.10.2.tar.gz | 53.8 kB | Without provenance | Details for betanegbinfit-1.10.2.tar.gz |
Release files / betanegbinfit-1.10.2.tar.gz
| Download URL | betanegbinfit-1.10.2.tar.gz |
|---|---|
| Size | 53.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89bc388d2cb15976ec030fb4b55e7933526424f1554ea02492e6b7e96d432751
|
|
BLAKE2b-256 checksum How to use checksums |
3f3b18dd93a84805e7c89cf249a89478bfbdf59ee1e06171ff728b21a43ae541
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.3
|
Security for betanegbinfit 1.10.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.