Package: betanegbinfit
BetaNegBinFitA very brief manualThe cornerstones (or rather, to be more precise, parts that are supposed to be used by a user, rather than a developer) ofBetaNegBinFitaremodelclasses 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 constrainingrparameter to a linear function of slice.Both models can use either negative-binomial or beta-negative-binomial distribution (seemodelargument of their__init__methods).Use example: *ModelMixture"RunningModelMixtureis 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 theresvariable which is a fairly self-explanotorydict.Some_slice?Assume that we want to get slice of refs with fix__c = 23 for BAD=3 for ourchipseq-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:ModelLineModelLineis ran similarly, but this time we pass whole data to thefitmethod 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,ModelLinewill try to guess ref count, alt count and BAD columns from the dataframe.Statisticsstatsmodule 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 & multiprocessingHowever, instead of manually creating instances of model classes and working throughBetaNegBinFitmethods, it might be much more preferential to run a single to-use function. The package hasutils.runfunction that is very easy to use and also does parallelization. Seetest.pyfor 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 throughhelp(function of interest).A note on performanceAs far as we are concerned,BetaNegBinFitshould work within a manageable amounts of time. For insance, whenModelLinewithmodel='BetaNB'ran againstchipseq.tsvdataset, it finishes in 6 minutes when ran at Ryzen 5600U. It does so under 2 minutes withmodel='NB'.