Learn R Programming

DEMIC

Introduction

DEMIC is an R package for comparing bacterial growth rates between metagenomic samples, based on inferred relative distances of contigs from replication origin according to their coverages. It works with a custom coverage report generated by PyCov3 that provides per-contig and per-sample coverage information for sliding windows over contigs.

Installation

DEMIC can be installed with:

install.packages("demic")

The development version can be installed from GitHub with:

# install.packages("devtools")
devtools::install_github("Ulthran/DEMIC")
library(demic)

Basic Usage

library(demic)
eptrs1 <- est_ptr(ContigCluster1)
eptrs2 <- est_ptr(ContigCluster2)

colnames(eptrs1)
# [1] "sample"      "est_ptr"     "coefficient" "pValue"      "cor"         "correctY"

eptrs1["sample"]
# 1 Sample1
# 2 Sample2
# 3 Sample3

eptrs1["est_ptr"]
# 1 1.588210
# 2 2.296994
# 3 1.840564

With a PyCov3 report:

X <- read.csv("cov3.cov3", stringsAsFactors = TRUE)
estptrs <- est_ptr(X)

Docs and Additional Help

This package is designed to be used with the COV3 output files of PyCov3. Its usage can be seen in the context of the sunbeam extension sbx_demic. Please cite Gao, Y., Li, H. Quantifying and comparing bacterial growth dynamics in multiple metagenomic samples. Nat Methods 15, 1041–1044 (2018). https://doi.org/10.1038/s41592-018-0182-0.

Copy Link

Version

Install

install.packages('demic')

Monthly Downloads

7

Version

2.0.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Charlie Bushman

Last Published

January 22nd, 2024

Functions in demic (2.0.0)

test_reasonable

A function to test whether the result is reasonable
est_ptrs_subset

Get PTR estimates for output of the core pipeline on a subset of data
select_by_ks_test

A function to remove outlier contigs using KS test
reshape_filtered

A function for reshape to facilitate PCA, removing all contigs with missing values for designated samples
pipeline

A function representing the pipeline of four steps including GC bias correction, sample filtration, PCA and contig filtration
max_bin_003

MaxBin2 Cluster 003
get_eptr_stats

Generate a variety of stats on PTR estimates for a given dataset
verify_input

Verify that the input dataframe/matrix is valid
est_ptr

Estimate PTRs using all input data as well as using subsets of contigs and samples
cor_diff

Determine the majority orientation of the input PTR estimates correlations
ContigCluster2

Contig Cluster 2
consist_transfer

A function for data frame integration
compare_sample_subsets

Compares sample subset x against sample subset y
df_transfer

A function for data frame transfer
ContigCluster1

Contig Cluster 1
est_ptr_on

Tries up to max_attempts times to compare each permutation of removing random subsets of contigs/samples from X, and returns the PTR estimate if a valid one comes back from the comparisons
compare_contig_subsets

Compares contig subset x against contig subset y
lm_column

A convenient function for ordinary linear regression on two vectors
ks

A convenient function for KS test of uniform distribution
contig_pca

A function to return the first dimension of PCA on an input matrix
iterate_pipelines

A function for iteration of pipeline until convergence
max_bin_002

MaxBin2 Cluster 002
est_ptr_on_all

Estimates PTRs based on the whole input dataset
lme4_model

Run mixed linear model with random effect using lme4
max_bin_001

MaxBin2 Cluster 001
filter_sample

A function for sample filtration Input requirements: 1. have values in more than half of the contigs 2. average log2(cov) > 0 in all these contigs