fit_logregr: Fit SINGLE's logistic regression

View source: R/fit_logregr.r

fit_logregrR Documentation

Fit SINGLE's logistic regression

Description

This is an auxiliary function in single package. It takes counts_pnq and for each position and nucleotide it fits SINGLE's logistic regression.

Usage

fit_logregr(
  counts_pnq,
  ref_seq,
  p_prior_errors,
  p_prior_mutations,
  save = FALSE,
  output_file_fits,
  output_file_data,
  verbose = FALSE,
  keep_fit_quality = FALSE
)

Arguments

counts_pnq

Data frame with columns position nucleoide quality counts, as returned by pileup_by_QUAL

ref_seq

DNAStringSet containing the true reference sequence.

p_prior_errors

Data frame with columns position nucleotide prior.error, as the one returned by p_prior_errors().

p_prior_mutations

Data frame with columns wt.base, nucleotide and p_mutation (probaility of mutation), as the one returned by p_prior_mutations().

save

Logical. Should data be saved in a output_file?

output_file_fits

File into which save the single fits if save=TRUE

output_file_data

File into which save the fitted data if save=TRUE

verbose

Logical.

keep_fit_quality

Logical. Should parameters related to the quality of the fit be returned in extra columns of the output?

Value

data.frame with columns position, nucleotide, slope and intercept (of the sigmoidal regression).

Examples

refseq_fasta <- system.file("extdata", "ref_seq.fasta", package = "single")
ref_seq = Biostrings::readDNAStringSet(refseq_fasta)
train_reads_example <- system.file("extdata", "train_seqs_500.sorted.bam",
                                   package = "single")
counts_pnq <- pileup_by_QUAL(bam_file=train_reads_example,
    pos_start=1,pos_end=10)
p_prior_mutations <- p_prior_mutations(rates.matrix = mutation_rate,
    mean.n.mut = 5,ref_seq = ref_seq)
p_prior_errors <- p_prior_errors(counts_pnq=counts_pnq)
fits <- fit_logregr(counts_pnq = counts_pnq,ref_seq=ref_seq,
    p_prior_errors = p_prior_errors,p_prior_mutations = p_prior_mutations)

rocioespci/single documentation built on April 18, 2023, 8:48 p.m.