Skip to content

Commit cf80e8d

Browse files
committed
add deme information for samples and along lineages with gendat
1 parent 385c1fb commit cf80e8d

24 files changed

+620
-59
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Collate:
4545
'simulate.R'
4646
'sir_pomp.R'
4747
'strains.R'
48+
'strains_pomp.R'
4849
'treeplot.R'
4950
'twospecies.R'
5051
'twospecies_pomp.R'

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export(simulate)
6969
export(sir_pomp)
7070
export(sirs_pomp)
7171
export(stew)
72+
export(strains_pomp)
7273
export(treeplot)
7374
export(twospecies_pomp)
7475
export(viewport)

R/gendat.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
##' @name gendat
66
##' @include package.R
77
##' @param object a \sQuote{gpgen} object.
8+
##' @inheritParams getInfo
89
##' @return A list of objects containing the information pertinent for filtering.
910
##' @rdname gendat
1011
##' @export
11-
gendat <- function (object) {
12-
.Call(P_gendat,geneal(object))
12+
gendat <- function (object, obscure = TRUE) {
13+
.Call(P_gendat,geneal(object),as.logical(obscure))
1314
}

R/getinfo.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ getInfo <- function (
4545
ndeme = FALSE, lineages = FALSE, newick = FALSE,
4646
nsample = FALSE, genealogy = FALSE, gendat = FALSE
4747
) {
48+
if (gendat & !prune) {
49+
warning("pruning since 'gendat=TRUE'",call.=FALSE)
50+
prune <- TRUE
51+
}
4852
x <- .External(
4953
P_getInfo,
5054
object=geneal(object),

R/strains_pomp.R

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
##' @name strains_pomp
2+
##' @rdname strains
3+
##' @include strains.R
4+
##' @param x genealogy in \pkg{phylopomp} format (i.e., an object that inherits from \sQuote{gpgen}).
5+
##' @details
6+
##' \code{strains_pomp} constructs a \sQuote{pomp} object containing a given set of data and the Strains model.
7+
##' @return
8+
##' \code{strains_pomp} returns a \sQuote{pomp} object.
9+
##' @importFrom pomp pomp onestep
10+
##' @export
11+
strains_pomp <- function (x, Beta1, Beta2, Beta3, gamma, psi1, psi2, psi3, S0, I1_0, I2_0, I3_0, R0, t0 = 0)
12+
{
13+
x |> gendat(obscure=FALSE) -> gi
14+
ic <- as.integer(c(S0,I1_0,I2_0,I3_0,R0))
15+
names(ic) <- c("S0","I1_0","I2_0","I3_0","R0")
16+
if (any(ic < 0))
17+
pStop(paste(sQuote(names(ic)),collapse=","),
18+
" must be nonnegative integers.")
19+
pomp(
20+
data=NULL,
21+
t0=gi$nodetime[1L],
22+
times=gi$nodetime[-1L],
23+
params=c(
24+
Beta1=Beta1,Beta2=Beta2,Beta3=Beta3,
25+
gamma=gamma,
26+
psi1=psi1,psi2=psi2,psi3=psi3,
27+
ic,N=sum(ic)
28+
),
29+
userdata=gi,
30+
rinit="strains_rinit",
31+
rprocess=onestep("strains_gill"),
32+
dmeasure="strains_dmeas",
33+
statenames=c(
34+
"S","I2","I2","I3","R",
35+
"ll","ell1","ell2","ell3","node"
36+
),
37+
paramnames=c(
38+
"Beta1","Beta2","Beta3","gamma",
39+
"psi1","psi2","psi3",
40+
"S0","I1_0","I2_0","I3_0","R0","N"
41+
),
42+
PACKAGE="phylopomp"
43+
)
44+
}

inst/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
_N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_h_y_l_o_p_o_m_p'
22

3+
_C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n _0._1_6:
4+
5+
• ‘gendat()’ now returns the deme for samples.
6+
37
_C_h_a_n_g_e_s _i_n '_p_h_y_l_o_p_o_m_p' _v_e_r_s_i_o_n _0._1_5:
48

59
• New model in which three distinct strains compete for

inst/NEWS.Rd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
\name{NEWS}
22
\title{News for package `phylopomp'}
3+
\section{Changes in \pkg{phylopomp} version 0.16}{
4+
\itemize{
5+
\item \code{gendat()} now returns the deme for samples.
6+
}
7+
}
38
\section{Changes in \pkg{phylopomp} version 0.15}{
49
\itemize{
510
\item New model in which three distinct strains compete for susceptibles from a single pool.

man/gendat.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/strains.Rd

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bare.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ extern "C" {
2929
}
3030

3131
//! data-frame format
32-
SEXP gendat (SEXP State) {
32+
SEXP gendat (SEXP State, SEXP Obscure) {
3333
genealogy_t A = State;
3434
A.prune();
35-
A.obscure();
35+
if (*LOGICAL(Obscure)) A.obscure();
3636
A.trace_lineages();
3737
return A.gendat();
3838
}

0 commit comments

Comments
 (0)