useDynLib(RPANDA, .registration = TRUE)

import(ape)
import(pspline)
import(methods)
import(glassoFast)


importFrom(BB,spg)
importFrom(bipartite,plotweb)
importFrom(cluster,pam)
importFrom(coda, mcmc.list, mcmc, gelman.diag, densplot)
importFrom(deSolve, ode)
importFrom(fields, image.plot)
importFrom(fpc,pamk)
importFrom(geiger,is.root)
importFrom(graphics, lines, mtext, par, plot, matplot,
           matlines, abline, text, points, polygon, layout, title,
           plot.new, rasterImage, axis, image, arrows, legend, rect)
importFrom(grDevices, dev.new, rainbow, terrain.colors,
           colorRampPalette, colors, grey)
importFrom(GUniFrac,GUniFrac)
importFrom(igraph, graph.adjacency, graph.laplacian)
importFrom(Matrix, Matrix)
importFrom(mvMORPH, mvLL, pruning, mvSIM, GIC, mv.Precalc, ancestral)
importFrom(mvtnorm, rmvnorm)
importFrom(ParallelLogger, clusterApply)
importFrom(parallel, mclapply, makeCluster, clusterExport, stopCluster)
importFrom(phangorn, Siblings, Ancestors, Descendants, Children)
importFrom(phytools, plotSimmap, make.simmap, nodeHeights, findMRCA, getDescendants, drop.tip.simmap, midpoint.root, reorderSimmap, splitTree, pbtree)
importFrom(picante, node.age)
importFrom(pracma,ifft)
importFrom(pvclust,pvclust,pvrect)
importFrom(raster, as.raster)
importFrom(RColorBrewer, brewer.pal)
importFrom(Rmpfr, mpfr, chooseMpfr)
importFrom(R.utils,withTimeout)
importFrom(stats, rnorm, runif, optim, integrate, smooth.spline, splinefun,
           as.dist, bw.nrd0, dnorm, heatmap, kmeans, na.omit, pnorm, predict,
           sd, var, reorder, rexp, cov2cor, rlnorm, density, fft, optimize, dist,
           cor, cov, model.matrix, quantile)
importFrom(TESS, tess.sim.age, tess.likelihood)
importFrom(utils, combn, tail, flush.console, read.table, write.table)
importFrom(vegan,vegdist)
importFrom("utils", "setTxtProgressBar", "txtProgressBar")

S3method(print, fit.env)
S3method(print, fit.bd)
S3method(print, fit_t.env)
S3method(print, fit_t.env.ou)
S3method(plot, fit_t.env)
S3method(plot, fit_t.env.ou)
S3method(lines, fit_t.env.ou)
S3method(lines, fit_t.env)
S3method(print, fit_pl.rpanda)
S3method(print, gic.rpanda)
S3method(GIC, fit_pl.rpanda)
S3method(ancestral, fit_pl.rpanda)
S3method(ancestral, fit_t.env)
S3method(ancestral, fit_t.comp)


export(fit_bd, fit_coal_cst, fit_coal_var, fit_env, BICompare, spectR, JSDtree, JSDtree_cluster, sim_env_bd, JSDt_cluster, spectR_t)
export(likelihood_bd, likelihood_coal_cst, likelihood_coal_var)
export(plot_dtt, plot_fit_bd, plot_fit_env, plot_spectR, plot_BICompare, sim_sgd)
export(fit_t_env,likelihood_t_env,sim_t_env,plot.fit_t.env,lines.fit_t.env)
export(fit_t_env_ou,sim_t_env_ou,plot.fit_t.env.ou,lines.fit_t.env.ou)
export(fit_t_pl, ancestral, phyl.pca_pl, gic_criterion, Posdef)
export("createModel", "createModelCoevolution", "getTipDistribution", "getDataLikelihood", "fitTipData", "modelSelection", "simulateTipData")
export(fit_t_comp,likelihood_t_MC,likelihood_t_MC_geog,likelihood_t_DD,likelihood_t_DD_geog,sim_t_comp,CreateGeoObject,sim.divergence.geo,sim.convergence.geo, CreateGeoObject_BioGeoBEARS,fit_t_standard,sim_t_tworegime)
export(fit_t_comp_subgroup,CreateClassObject,CreateGeobyClassObject,likelihood_subgroup_model)
export(plot_prob_dtt, prob_dtt)
export(plot_ClaDS_phylo, sim_ClaDS, fit_ClaDS0, plot_ClaDS0_chains, plot_ClaDS_chains,
       getMAPS_ClaDS, getMAPS_ClaDS0, fit_ClaDS)
export(sim_MCBD)
export(phylosignal_network,phylosignal_sub_network,plot_phylosignal_sub_network,mantel_test,mantel_test_nbpartners)
export(theta_estimator,pi_estimator,delineate_phylotypes)
export(fit_bd_in_past,fit_env_in_past)
export(sim.BipartiteEvol,make_gen.BipartiteEvol,define_species.BipartiteEvol,build_network.BipartiteEvol,
       plot_div.BipartiteEvol, plot_net.BipartiteEvol)
export(add.gts, apply_prob_dtt, div.models, div.rates, fit_bd_backbone_c, fit_bd_backbone, get.comb.shift, get.sampling.fractions, likelihood_bd_backbone, paleodiv, plot_phylo_comb, plot_prob_dtt, remove.model, shift.estimates, apply_prob_dtt, simul.comb.shift)

exportClasses("PhenotypicModel", "PhenotypicACDC", "PhenotypicADiag", "PhenotypicBM", "PhenotypicDD", "PhenotypicGMM", "PhenotypicOU", "PhenotypicPM")


exportMethods("print", "show", "[", "getTipDistribution", "getDataLikelihood", "fitTipData", "modelSelection", "simulateTipData")
