Title: | A Network Tool to Dissect Spatial Community Ecology |
---|---|
Description: | Most existing approaches for network reconstruction can only infer an overall network and, also, fail to capture a complete set of network properties. To address these issues, a new model has been developed, which converts static data into their 'dynamic' form. 'idopNetwork' is an 'R' interface to this model, it can inferring informative, dynamic, omnidirectional and personalized networks. For more information on functional clustering part, see Kim et al. (2008) <doi:10.1534/genetics.108.093690>, Wang et al. (2011) <doi:10.1093/bib/bbr032>. For more information on our model, see Chen et al. (2019) <doi:10.1038/s41540-019-0116-1>, and Cao et al. (2022) <doi:10.1080/19490976.2022.2106103>. |
Authors: | Ang Dong |
Maintainer: | Ang Dong <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.2 |
Built: | 2025-01-27 04:25:46 UTC |
Source: | https://github.com/cxzdsa2332/idopnetwork |
main function for bifunctional clustering
bifun_clu( data1, data2, k, Time1 = NULL, Time2 = NULL, trans = log10, inv.cov = NULL, initial.pars = NULL, iter.max = 100, parscale = 0.001 )
bifun_clu( data1, data2, k, Time1 = NULL, Time2 = NULL, trans = log10, inv.cov = NULL, initial.pars = NULL, iter.max = 100, parscale = 0.001 )
data1 |
matrix or data for cluster |
data2 |
matrix or data for cluster |
k |
vector for the cluster number |
Time1 |
vector for the time point |
Time2 |
vector for the time point |
trans |
indicate log/log2/log10 transform dataset |
inv.cov |
matrix for directly solve cov matrix, default not given(currently not available) |
initial.pars |
vector for manual give initial parameters, default not given |
iter.max |
scales control iteration for EM algorithm |
parscale |
scales control parameters scales for cov pars |
the initial parameters for functional clustering
convert result of bifunctional clustering result
bifun_clu_convert(result, best.k)
bifun_clu_convert(result, best.k)
result |
list directly from bifun_clu_parallel function |
best.k |
scale of BIC-determined cluster number |
list contain module data and fitted data
parallel version for functional clustering
bifun_clu_parallel( data1, data2, Time1 = NULL, Time2 = NULL, trans = log10, start, end, iter.max = 100, thread = 2 )
bifun_clu_parallel( data1, data2, Time1 = NULL, Time2 = NULL, trans = log10, start, end, iter.max = 100, thread = 2 )
data1 |
data for cluster |
data2 |
data for cluster |
Time1 |
vector for the time point |
Time2 |
vector for the time point |
trans |
indicate log/log2/log10 transform dataset |
start |
vector for the minimum cluster number |
end |
vector for the maximum cluster number |
iter.max |
scales control iteration for EM algorithm |
thread |
scales for how many thread used |
the initial parameters for functional clustering
bifunctional clustering plot
bifun_clu_plot( result, best.k, label = 10, degree = 1/4, show.legend = FALSE, color1 = "#38E54D", color2 = "#FF8787" )
bifun_clu_plot( result, best.k, label = 10, degree = 1/4, show.legend = FALSE, color1 = "#38E54D", color2 = "#FF8787" )
result |
list directly from bifun_clu_parallel function |
best.k |
scale of BIC-determined cluster number |
label |
relabel x and y label due to log-transform, set 10 as default |
degree |
scalar control transparency degree |
show.legend |
show legend or not |
color1 |
Hex Color Codes for first data |
color2 |
Hex Color Codes for second data |
functional clustering plot
acquire initial parameters for functional clustering
biget_par_int(X, k, times1, times2, n1, n2)
biget_par_int(X, k, times1, times2, n1, n2)
X |
matrix for cluster |
k |
vector for the cluster number |
times1 |
vector for the x values or time points |
times2 |
vector for the x values or time points |
n1 |
scalar for number of column contain first trait/location etc |
n2 |
scalar for number of column contain second trait/location etc |
the initial parameters for functional clustering
plot power equation fitting results for bi-variate model
bipower_equation_plot( result, label = 10, n = 9, show.legend = FALSE, color1 = "#38E54D", color2 = "#FF8787" )
bipower_equation_plot( result, label = 10, n = 9, show.legend = FALSE, color1 = "#38E54D", color2 = "#FF8787" )
result |
list object returned from data_match |
label |
relabel x and y label due to log-transform, set 10 as default |
n |
scales for how many subplots needed |
show.legend |
show legend or not |
color1 |
Hex Color Codes for first data |
color2 |
Hex Color Codes for second data |
plot show power curve fitting result
Q-function to replace log-likelihood function
biQ_function(par, prob_log, omega_log, X, k, n1, n2, times1, times2)
biQ_function(par, prob_log, omega_log, X, k, n1, n2, times1, times2)
par |
numeric vector for parameters need to be estimated |
prob_log |
mixture component weights(log) |
omega_log |
latent variables(log) |
X |
matrix for cluster |
k |
vector for the cluster number |
n1 |
scalar for number of column contain first trait/location etc |
n2 |
scalar for number of column contain second trait/location etc |
times1 |
vector for the x values or time points |
times2 |
vector for the x values or time points |
the Loglikelihood value
plot all decompose plot for two data
biqdODE_plot_all( result1, result2, label = 10, show.legend = FALSE, remove.label = TRUE, nrow = NULL, ncol = NULL )
biqdODE_plot_all( result1, result2, label = 10, show.legend = FALSE, remove.label = TRUE, nrow = NULL, ncol = NULL )
result1 |
list of qdODE all for first data |
result2 |
list of qdODE all for second data |
label |
relabel x and y label due to log-transform, set 10 as default |
show.legend |
to show legend |
remove.label |
to remove x and y label |
nrow |
scalar for subplot row number |
ncol |
scalar for subplot column number |
plot single decompose plot for two data
biqdODE_plot_base( result1, result2, label = 10, show.legend = FALSE, remove.label = FALSE )
biqdODE_plot_base( result1, result2, label = 10, show.legend = FALSE, remove.label = FALSE )
result1 |
list of qdODE all for first data |
result2 |
list of qdODE all for second data |
label |
relabel x and y label due to log-transform, set 10 as default |
show.legend |
to show legend |
remove.label |
to remove x and y label |
make color more dark
darken(color, factor = 1.2)
darken(color, factor = 1.2)
color |
hex color code |
factor |
scalar for darken level |
darkened hex color code
darken("#FF0000")
darken("#FF0000")
remove observation with too many 0 values
data_cleaning(data, x = round(ncol(data) * 0.3))
data_cleaning(data, x = round(ncol(data) * 0.3))
data |
dataframe of imported dataset, must have first column as ID |
x |
scales indicate how many 0 to remove |
a dataframe without too many 0 observations
data_cleaning(matrix(c(c(0,1,1,0,0,1,1), c(2,1,0,3,5,2,2), c(1,1,3,2,4,5,1)), 3, 7), 2)
data_cleaning(matrix(c(c(0,1,1,0,0,1,1), c(2,1,0,3,5,2,2), c(1,1,3,2,4,5,1)), 3, 7), 2)
match power_equation fit result for bi-variate model
data_match(result1, result2)
data_match(result1, result2)
result1 |
list object from power_equation fit |
result2 |
list object from power_equation fit |
a id match list for input dataset
main function for functional clustering
fun_clu( data, k, Time = NULL, trans = log10, inv.cov = NULL, initial.pars = NULL, iter.max = 100, parscale = 0.1 )
fun_clu( data, k, Time = NULL, trans = log10, inv.cov = NULL, initial.pars = NULL, iter.max = 100, parscale = 0.1 )
data |
matrix or data for cluster |
k |
vector for the cluster number |
Time |
vector for the time point |
trans |
indicate log/log2/log10 transform dataset |
inv.cov |
matrix for directly solve cov matrix, default not given(currently not available) |
initial.pars |
vector for manual give initial parameters, default not given |
iter.max |
scales control iteration for EM algorithm |
parscale |
scales control parameters scales for cov pars |
the initial parameters for functional clustering
plot BIC results for functional clustering
fun_clu_BIC(result, crit = "BIC", title = NULL)
fun_clu_BIC(result, crit = "BIC", title = NULL)
result |
list directly from fun_clu_parallel function |
crit |
either BIC or AIC for module selection |
title |
title for the plot |
the BIC plot
convert result of functional clustering result
fun_clu_convert(result, best.k)
fun_clu_convert(result, best.k)
result |
list directly from fun_clu_parallel function |
best.k |
scale of BIC-determined cluster number |
list contain module data and fitted data
parallel version for functional clustering
fun_clu_parallel( data, Time = NULL, trans = log10, start, end, iter.max = 100, thread = 2 )
fun_clu_parallel( data, Time = NULL, trans = log10, start, end, iter.max = 100, thread = 2 )
data |
data for cluster |
Time |
vector for the time point |
trans |
indicate log/log2/log10 transform dataset |
start |
vector for the minimum cluster number |
end |
vector for the maximum cluster number |
iter.max |
scales control iteration for EM algorithm |
thread |
scales for how many threads used |
the initial parameters for functional clustering
functional clustering plot
fun_clu_plot(result, best.k, label = 10, degree = 1)
fun_clu_plot(result, best.k, label = 10, degree = 1)
result |
list directly from fun_clu_parallel function |
best.k |
scalar of BIC-determined cluster number |
label |
relabel x and y label due to log-transform, set 10 as default |
degree |
scalar control transparency degree |
functional clustering plot
select result of functional clustering result
fun_clu_select(result_fit, result_funclu, i)
fun_clu_select(result_fit, result_funclu, i)
result_fit |
list directly from power_equation_fit |
result_funclu |
list from fun_clu_convert |
i |
scale of which cluster selected |
list contain microbe data and fitted data
generate biSAD1 covariance matrix
get_biSAD1(par, n1, n2)
get_biSAD1(par, n1, n2)
par |
vector with four number, first two for ck and the rest for stress |
n1 |
scalar indicate length of time1 |
n2 |
scalar indicate length of time2 |
biSAD1 covariance matrix
get_biSAD1(par=c(2,0.5,2,0.1),n1=4, n2 = 5)
get_biSAD1(par=c(2,0.5,2,0.1),n1=4, n2 = 5)
Lasso-based variable selection
get_interaction(data, col, reduction = FALSE)
get_interaction(data, col, reduction = FALSE)
data |
data of clustered results, do not contain cluster column |
col |
scalar of which row number selected |
reduction |
use n/log(n) dimension reduction |
list contain relationship of each row
generate legendre matrix
get_legendre_matrix(x, legendre_order)
get_legendre_matrix(x, legendre_order)
x |
vector equal to the x value for legendre polynomials(in this case times) |
legendre_order |
the order of legendre polynomials |
the polynomials value of each order
get_legendre_matrix(1:14,4)
get_legendre_matrix(1:14,4)
use legendre polynomials to fit a given data
get_legendre_par(y, legendre_order, x)
get_legendre_par(y, legendre_order, x)
y |
vector equal to the y observed data(in this case generic effect) |
legendre_order |
scalar of legendre polynomials |
x |
vector equal to the x value for legendre polynomials(in this case times) |
the polynomials coefficients
get_legendre_par(14:1,4,1:14)
get_legendre_par(14:1,4,1:14)
curve fit with modified logistic function
get_mu(mu_par, times)
get_mu(mu_par, times)
mu_par |
vector with five number |
times |
vector of time point |
numeric vector with the same length to times
get_mu(mu_par = 1:5, times = 1:14)
get_mu(mu_par = 1:5, times = 1:14)
generate mean vectors with ck and stress condition
get_mu2(par, times)
get_mu2(par, times)
par |
vector with ten number, first five for ck and the rest for stress |
times |
vector of time point |
numeric vector with the double length to times
get_mu2(par = 1:10, times = 1:14)
get_mu2(par = 1:10, times = 1:14)
acquire initial parameters for functional clustering
get_par_int(X, k, times)
get_par_int(X, k, times)
X |
matrix for cluster |
k |
vector for the cluster number |
times |
vector for the x values or time points |
the initial parameters for functional clustering
generate standard SAD1 covariance matrix
get_SAD1_covmatrix(par, n)
get_SAD1_covmatrix(par, n)
par |
vector with two number for SAD1 covariance matrix |
n |
scalar indicate length of time d |
SAD1 covariance matrix
get_SAD1_covmatrix(par = c(2,0.5), n = 14)
get_SAD1_covmatrix(par = c(2,0.5), n = 14)
The original nucleotide sequences of this study were deposited to the NCBI Sequence Read Archive under accession number SRP128619.
data(gut_microbe)
data(gut_microbe)
A data frame with 65 rows and 21 column, contain first column as microbe ID:
generate curve based on legendre polynomials
legendre_fit(par, x)
legendre_fit(par, x)
par |
vector of legendre polynomials coefficients |
x |
vector equal to the x value for legendre polynomials(in this case times) |
the polynomials value
legendre_fit(rep(1,5),1:14)
legendre_fit(rep(1,5),1:14)
calculate log-sum-exp values
logsumexp(v)
logsumexp(v)
v |
numeric vector |
log-sum-exp values
logsumexp(c(100, 1000, 10000))
logsumexp(c(100, 1000, 10000))
Wagner, M. R. et al. Host genotype and age shape the leaf and root microbiomes of a wild perennial plant. Nat. Commun. 7:12151 doi: 10.1038/ncomms12151 (2016) This dataset is a subset of otuTable97, we select location = JAM, keep samples with both root and leaf data, and then run data_cleaning first (set x = 50) to reduce size of this data. Moreover, sample 8_1382 is removed for the outlier reason.
data(mustard_microbe)
data(mustard_microbe)
A data frame with 1557 rows and 176 column, contain first column as OTU ID:
convert ODE results(ODE_solving2) to basic network plot table
network_conversion(result)
network_conversion(result)
result |
list result from qsODE_parallel |
a list with basic information to plot network
convert ODE results(ODE_solving2) to basic network plot table
network_maxeffect(result)
network_maxeffect(result)
result |
list result from qsODE_parallel |
a list with basic information to plot network
generate network plot
network_plot(result, title = NULL, maxeffect = NULL, type = NULL)
network_plot(result, title = NULL, maxeffect = NULL, type = NULL)
result |
list result from network_conversion |
title |
text for plot title |
maxeffect |
control edge size when compare networks |
type |
select module effect or microbe effect |
network plot
min-max normalization
normalization(x, z = 0.2)
normalization(x, z = 0.2)
x |
numeric vector |
z |
scalar add minimum value to avoid 0 |
normalized vector
normalization(runif(100,min = -100, max = 100))
normalization(runif(100,min = -100, max = 100))
use power equation parameters to generate y values
power_equation(x, power_par)
power_equation(x, power_par)
x |
vector for x values |
power_par |
matrix contain parameters for power equation |
y values for given power equation parameters
power_equation(c(1,2,3,5,7), matrix(c(2,1,1,2),2,2))
power_equation(c(1,2,3,5,7), matrix(c(2,1,1,2),2,2))
use power equation to fit observed values
power_equation_all(x, y, maxit = 100)
power_equation_all(x, y, maxit = 100)
x |
vector for x values |
y |
vector for y values |
maxit |
numeric value for maximum initial pars try |
nls model
power_equation_all(c(1,2,3,5,7), c(5,10,15,17,20))
power_equation_all(c(1,2,3,5,7), c(5,10,15,17,20))
use power equation to fit observed values
power_equation_base(x, y)
power_equation_base(x, y)
x |
vector for x values |
y |
vector for y valyes |
nls model
power_equation_base(c(1,2,3,5,7), c(5,10,15,17,20))
power_equation_base(c(1,2,3,5,7), c(5,10,15,17,20))
use power equation to fit given dataset
power_equation_fit(data, n = 30, trans = log10, thread = 2)
power_equation_fit(data, n = 30, trans = log10, thread = 2)
data |
cleaned dataframe |
n |
scales for how many interpolation needed |
trans |
indicate log/log2/log10 transform dataset |
thread |
scales for how many thread used |
list contain power equation parameters and fitted data
plot power equation fitting results
power_equation_plot(result, label = 10, n = 9)
power_equation_plot(result, label = 10, n = 9)
result |
list object returned from power_equation_fit |
label |
relabel x and y label due to log-transform, set 10 as default |
n |
scales for how many subplots needed |
plot show power curve fitting result
Q-function to replace log-likelihood function
Q_function(par, prob_log, omega_log, X, k, times)
Q_function(par, prob_log, omega_log, X, k, times)
par |
numeric vector for parameters need to be estimated |
prob_log |
mixture component weights(log) |
omega_log |
latent variables(log) |
X |
matrix for cluster |
k |
vector for the cluster number |
times |
vector for the x values or time points |
the Loglikelihood value
wrapper for qdODE model
qdODE_all( result, relationship, i, init_pars = 1, LOP_order = 6, method = "ls", new_time = NULL, n_expand = 100, maxit = 1000 )
qdODE_all( result, relationship, i, init_pars = 1, LOP_order = 6, method = "ls", new_time = NULL, n_expand = 100, maxit = 1000 )
result |
result from power_equation_fit |
relationship |
list contain variable selection results |
i |
scalar for which id used for qdODE solving, must <= nrow |
init_pars |
scalar for initial parameters |
LOP_order |
scalar of LOP order |
method |
scalar of qdODE solving methodm, cuurent only support least square |
new_time |
vector produce new defined time point |
n_expand |
scalar for how many interpolation needed |
maxit |
scalar of Optim iteration setting |
list contain variable selection results and LOP parameters for every row
legendre polynomials fit to qdODE model
qdODE_fit( pars, data, Time, power_par, LOP_order = 6, new_time = NULL, n_expand = 100 )
qdODE_fit( pars, data, Time, power_par, LOP_order = 6, new_time = NULL, n_expand = 100 )
pars |
vector of qdODE parameters |
data |
dataframe of observed data |
Time |
vector of time point |
power_par |
matrix of power equation parameters for dependent effect |
LOP_order |
scalar of LOP order |
new_time |
vector produce new defined time point |
n_expand |
scalar for how many interpolation needed |
list contain legendre polynomials parameters, qdODE values and LOP fitted values
least-square fit for qdODE model
qdODE_ls(pars, data, Time, power_par)
qdODE_ls(pars, data, Time, power_par)
pars |
vector for unknown ODE parameters |
data |
data contain independent effect as first row and dependent effect |
Time |
vector of time point |
power_par |
matrix of power equation parameters for dependent effect |
mean-square error
wrapper for qdODE_all in parallel version
qdODE_parallel(result, reduction = FALSE, thread = 2, maxit = 1000)
qdODE_parallel(result, reduction = FALSE, thread = 2, maxit = 1000)
result |
result from power_equation_fit |
reduction |
use n/log(n) dimension reduction |
thread |
scales for how many threads used |
maxit |
scalar of Optim iteration setting |
list contain variable selection results and LOP parameters for every row
plot all decompose plot
qdODE_plot_all( result, label = 10, show.legend = TRUE, nrow = NULL, ncol = NULL )
qdODE_plot_all( result, label = 10, show.legend = TRUE, nrow = NULL, ncol = NULL )
result |
list of qdODE parallel |
label |
relabel x and y label due to log-transform, set 10 as default |
show.legend |
to show legend |
nrow |
scalar for subplot row number |
ncol |
scalar for subplot column number |
all effect curve decompose plot
plot single decompose plot
qdODE_plot_base(result, label = 10, show.legend = TRUE)
qdODE_plot_base(result, label = 10, show.legend = TRUE)
result |
list of qdODE all |
label |
relabel x and y label due to log-transform, set 10 as default |
show.legend |
to show legend |
quasi-dynamic lotka volterra model
qdODEmod(Time, State, Pars, power_par)
qdODEmod(Time, State, Pars, power_par)
Time |
vector of time point |
State |
vector of ODE initial state |
Pars |
vector for unknown ODE parameters |
power_par |
matrix of power equation parameters for dependent effect |
list used in ode function
convert qdODE results to plot data
qdODEplot_convert(result)
qdODEplot_convert(result)
result |
list of qdODE all |