weighted_consensus: Compute consensus sequence

View source: R/weighted_consensus.r

weighted_consensusR Documentation

Compute consensus sequence

Description

This is an auxiliary function in single package. It computes consensus from a data.frame as the one returned by single_evaluate()

Usage

weighted_consensus(df, cutoff_prob = 0.2)

Arguments

df

data.frame with the columns: nucleotide, probability, position

cutoff_prob

Numeric. Nucleotides with probability below this number will be removed from consensus computation.

Value

Character vector, consensus sequence

Examples

fastq_seqs_example <- system.file("extdata", "test_sequences.fastq",package = "single")
seqs_example <- Biostrings::readQualityScaledDNAStringSet(fastq_seqs_example)
# Using single weights
data_barcode = data.frame(
 nucleotide = unlist(sapply(as.character(seqs_example),strsplit, split="")),
 p_SINGLe=unlist(1-as(Biostrings::quality(seqs_example),"NumericList")),
 pos=rep(1:Biostrings::width(seqs_example[1]),length(seqs_example)))
weighted_consensus(df = data_barcode, cutoff_prob = 0.9)
# Replacing weights by ones
data_barcode = data.frame(
 nucleotide = unlist(sapply(as.character(seqs_example),strsplit, split="")),
 p_SINGLe=1,pos=rep(1,sum(Biostrings::width(seqs_example))))
weighted_consensus(df = data_barcode, cutoff_prob = 0)

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