Commit 5fefb79a by Eric Coissac

Ajoute un example de debut de fichier genotype.R

parent 3580533e
......@@ -5,6 +5,10 @@ export(error_jc)
export(log_add_exp)
export(log_diff_exp)
export(log_sum_exp)
export(pdata_genotype)
export(pnuc_genotype)
export(pnuc_hetero_genotype)
export(pnuc_homo_genotype)
export(sequencing_error)
export(simulate_sites)
import(dplyr)
......
#' Compute probabilty of data knowing the genotype.
#'
#' @param obs.a the number of observed `A`
#' @param obs.c the number of observed `C`
#' @param obs.g the number of observed `G`
#' @param obs.t the number of observed `T`
#' @param haplotype.1 a character indicating the first haplotype
#' (A, C, G, ou T)
#' @param haplotype.2 a character indicating the second haplotype
#' (A, C, G, ou T)
#' @param sequencing.error a numeric ranging betweing 0 and 1
#' indicating the sequencing error rate
#'
#' @return returns the log of the probality of the data
#' knowning the genotype.
#'
#' @examples
#' pdata_genotype(4,3,0,1,'A','C',0.01)
#'
#' @export
pdata_genotype = function(obs.a,obs.c,obs.g,obs.t,
haplotype.1,haplotype.2,
sequencing.error) {
}
#' Compute probability of nucleotide observation knowning genotype.
#'
#' @param haplotype.1 a character indicating the first haplotype
#' (A, C, G, ou T)
#' @param haplotype.2 a character indicating the second haplotype
#' (A, C, G, ou T)
#' @param sequencing.error a numeric ranging betweing 0 and 1
#' indicating the sequencing error rate
#'
#' @return a vector of four probabilities for A, C, G and T
#' observations
#'
#' @examples
#' pnuc_genotype("A","T",0.01)
#'
#' @export
pnuc_genotype = function(haplotype.1,haplotype.2,
sequencing.error) {
if (haplotype.1 == haplotype.2)
rep = pnuc_homo_genotype(haplotype.1,sequencing.error)
else
rep = pnuc_hetero_genotype(haplotype.1,
haplotype.2,
sequencing.error)
return(rep)
}
#' Compute probability of nucleotide observation
#' knowning an heterozygote genotype.
#'
#' @param haplotype.1 a character indicating the first haplotype
#' (A, C, G, ou T)
#' @param haplotype.2 a character indicating the second haplotype
#' (A, C, G, ou T)
#' @param sequencing.error a numeric ranging betweing 0 and 1
#' indicating the sequencing error rate
#'
#' @return a vector of four probabilities for A, C, G and T
#' observations
#'
#' @examples
#' pnuc_hetero_genotype("A","T",0.01)
#'
#' @export
pnuc_hetero_genotype = function(haplotype.1,haplotype.2,
sequencing.error) {
pnuc = rep(sequencing.error/6*5,4)
names(pnuc)=c("A","C","G","T")
pnuc[haplotype.1] = 0.5 - sequencing.error/6*5
pnuc[haplotype.2] = pnuc[haplotype.1]
return(pnuc)
}
#' Compute probability of nucleotide observation
#' knowning an homozygote genotype.
#'
#' @param haplotype a character indicating the first haplotype
#' (A, C, G, ou T)
#' @param sequencing.error a numeric ranging betweing 0 and 1
#' indicating the sequencing error rate
#'
#' @return a vector of four probabilities for A, C, G and T
#' observations
#'
#' @examples
#' pnuc_hetero_genotype("A","T",0.01)
#'
#' @export
pnuc_homo_genotype = function(haplotype,
sequencing.error) {
pnuc = rep(sequencing.error/3,4)
names(pnuc)=c("A","C","G","T")
pnuc[haplotype] = 1 - sequencing.error
return(pnuc)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/genotype.R
\name{pdata_genotype}
\alias{pdata_genotype}
\title{Compute probabilty of data knowing the genotype.}
\usage{
pdata_genotype(obs.a, obs.c, obs.g, obs.t, haplotype.1, haplotype.2,
sequencing.error)
}
\arguments{
\item{obs.a}{the number of observed `A`}
\item{obs.c}{the number of observed `C`}
\item{obs.g}{the number of observed `G`}
\item{obs.t}{the number of observed `T`}
\item{haplotype.1}{a character indicating the first haplotype
(A, C, G, ou T)}
\item{haplotype.2}{a character indicating the second haplotype
(A, C, G, ou T)}
\item{sequencing.error}{a numeric ranging betweing 0 and 1
indicating the sequencing error rate}
}
\value{
returns the log of the probality of the data
knowning the genotype.
}
\description{
Compute probabilty of data knowing the genotype.
}
\examples{
pdata_genotype(4,3,0,1,'A','C',0.01)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/genotype.R
\name{pnuc_genotype}
\alias{pnuc_genotype}
\title{Compute probability of nucleotide observation knowning genotype.}
\usage{
pnuc_genotype(haplotype.1, haplotype.2, sequencing.error)
}
\arguments{
\item{haplotype.1}{a character indicating the first haplotype
(A, C, G, ou T)}
\item{haplotype.2}{a character indicating the second haplotype
(A, C, G, ou T)}
\item{sequencing.error}{a numeric ranging betweing 0 and 1
indicating the sequencing error rate}
}
\value{
a vector of four probabilities for A, C, G and T
observations
}
\description{
Compute probability of nucleotide observation knowning genotype.
}
\examples{
pnuc_genotype("A","T",0.01)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/genotype.R
\name{pnuc_hetero_genotype}
\alias{pnuc_hetero_genotype}
\title{Compute probability of nucleotide observation
knowning an heterozygote genotype.}
\usage{
pnuc_hetero_genotype(haplotype.1, haplotype.2, sequencing.error)
}
\arguments{
\item{haplotype.1}{a character indicating the first haplotype
(A, C, G, ou T)}
\item{haplotype.2}{a character indicating the second haplotype
(A, C, G, ou T)}
\item{sequencing.error}{a numeric ranging betweing 0 and 1
indicating the sequencing error rate}
}
\value{
a vector of four probabilities for A, C, G and T
observations
}
\description{
Compute probability of nucleotide observation
knowning an heterozygote genotype.
}
\examples{
pnuc_hetero_genotype("A","T",0.01)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/genotype.R
\name{pnuc_homo_genotype}
\alias{pnuc_homo_genotype}
\title{Compute probability of nucleotide observation
knowning an homozygote genotype.}
\usage{
pnuc_homo_genotype(haplotype, sequencing.error)
}
\arguments{
\item{haplotype}{a character indicating the first haplotype
(A, C, G, ou T)}
\item{sequencing.error}{a numeric ranging betweing 0 and 1
indicating the sequencing error rate}
}
\value{
a vector of four probabilities for A, C, G and T
observations
}
\description{
Compute probability of nucleotide observation
knowning an homozygote genotype.
}
\examples{
pnuc_hetero_genotype("A","T",0.01)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment