Skip to content

Commit

Permalink
version 3.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tpq authored and cran-robot committed May 9, 2018
1 parent 5e711ff commit 027651e
Show file tree
Hide file tree
Showing 21 changed files with 374 additions and 465 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: propr
Title: Calculating Proportionality Between Vectors of Compositional
Data
Version: 3.1.9
Version: 3.5.1
URL: http://github.com/tpq/propr
BugReports: http://github.com/tpq/propr/issues
Authors@R: c(
Expand Down Expand Up @@ -32,12 +32,12 @@ Suggests: ALDEx2, cccrm, compositions, data.table, datasets,
rgl, rmarkdown, SDMTools, testthat
LinkingTo: Rcpp
NeedsCompilation: yes
Packaged: 2018-04-19 00:00:02 UTC; thom
Packaged: 2018-05-09 01:48:34 UTC; thom
Author: Thomas Quinn [aut, cre],
David Lovell [aut],
Ionas Erb [aut],
Anders Bilgrau [ctb],
Greg Gloor [ctb]
Maintainer: Thomas Quinn <contacttomquinn@gmail.com>
Repository: CRAN
Date/Publication: 2018-04-19 04:10:05 UTC
Date/Publication: 2018-05-09 03:43:57 UTC
39 changes: 19 additions & 20 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
1ffdf8ec2915ab1b1eca17c8c34019a5 *DESCRIPTION
fc9034b46abebe095a17696814cfc4b3 *DESCRIPTION
67ad403fd221283af33b24ffc37b4fd8 *NAMESPACE
f881bd63447a2352ab1c6efb94a697c2 *NEWS.md
09715a185d439050a5c7e12b022612b2 *R/RcppExports.R
24dcf40b9d3bce4801593760c01363df *NEWS.md
b22faeb6033e49f28635d3ec30ff492b *R/RcppExports.R
01cde507c5d5e55e797ad1139adeed3e *R/aldex2propr.R
b887c19bf022fe5fe5cdc8565d3c0531 *R/deprecated.R
2fbcdaffc254f5b4aee9f1e080326c55 *R/deprecated2.R
ee216c19cd786f9d3501f736780cf5e2 *R/deprecated2.R
4193beec8873d32eb99f90e9f3e82229 *R/global.R
8d979d49e6d2de0c716c9a6c12795236 *R/methods.R
0b4893e99cb5bc7cfd80236b7a2d9337 *R/prop2prob.R
4b5c044bf142272158ceededbb5bfa8c *R/propd.R
0e126ff63320319a543289fb6ab0e94f *R/propdViz.R
6819a669157783bf4a799d6197259d94 *R/propr.R
40af66f0884ddb0ca671d8dd5596df99 *R/proprViz.R
064a93b09a8f5d3bed50bddec8100287 *R/theta.R
bc86989d0ed40343de5176b177b0404f *README.md
54feffc2b9c3a143fcbfa07507aefb3e *R/theta.R
1cf8dd6154e5275c4de7dd8942d9cc11 *README.md
22a039be116f8276dff48ab7bd576827 *build/vignette.rds
85afe8e966882d64a79de4ad8f198689 *data/caneToad.counts.rda
73203b36c5c9e855bd52d9beefaf5195 *data/caneToad.groups.rda
Expand All @@ -24,32 +24,31 @@ adc04cddc13d546ed30be8cd05f0c29c *data/marg.abs.rda
4fe6f1c8b45eac1bdb1b093cdf4fa6f7 *data/pd.e.rda
7c2f3c5e5bd43dc0aa8337c68d8f1342 *data/top.counts.rda
ed6a318a02091045e6fd3b1064cd7929 *data/top.lr.rda
59fcda9aeab43b39cd401570d2032bf3 *inst/CITATION
f57571343777ae1a27f4478b74033539 *inst/CITATION
d6a4f4909809cf0821ed36b27e61626e *inst/doc/a_introduction.R
402488ed5ba1db09ff73ad27048a7237 *inst/doc/a_introduction.Rmd
97959053258f9f2280fedaab19ac6fd1 *inst/doc/a_introduction.html
19ccfa3839d1b92ef63500feebc982c1 *inst/doc/a_introduction.html
14f4490bc3e4efb16a9d1362a307e028 *inst/doc/b_visualization.R
d8d1dd725e2aab656a24cc08501182a8 *inst/doc/b_visualization.Rmd
c6d46a82567f057d782434fc9fa643f5 *inst/doc/b_visualization.html
d38fc86b56c4251025f19e837d014dbc *inst/doc/b_visualization.html
5a702793dda9feab01e7b6618ad58eb6 *inst/doc/c_indexing.R
9de81db8ce7fa892d22b2fd894c19a6c *inst/doc/c_indexing.Rmd
3ef39dfe0fed1d8752b0218d0f9e3f35 *inst/doc/c_indexing.html
cac6af878c834cf4dad2450722177817 *inst/doc/c_indexing.html
5b1a171414afb1ce949c7a5b3639cb01 *inst/doc/d_advanced.R
6a87b21d11dabed7887cdbbc7383a019 *inst/doc/d_advanced.Rmd
f1ab8c217fbe54bd5266644d52a46827 *inst/doc/d_advanced.html
ed2f2f2753079e107277106ba9d590c0 *inst/doc/d_advanced.html
9407e268cc21208de2b8dcd092605967 *inst/doc/e_differential.R
96506e8c9dc36e25719cdf7e91bd9801 *inst/doc/e_differential.Rmd
e9634c179cad79e5688e8b28002f61dc *inst/doc/e_differential.html
e5e7826ff2584114ac1f143a0d406ffc *inst/doc/e_differential.html
c1afe056b198d5d0567c5492f01248a0 *inst/doc/f_moderation.R
07d5fe2a0aafe33f1b2e3a65b9774556 *inst/doc/f_moderation.Rmd
669bd909c0c95cff1f1e8195442fc6dd *inst/doc/f_moderation.html
a8b7cd83c0b8dcf3e8d7db3049ae2f84 *inst/doc/f_moderation.html
33a9bed57d1e32b52a309e6280fd2ddd *inst/doc/g_questions.R
5dad600aff5ba8daa8b5a7604a3b8bbd *inst/doc/g_questions.Rmd
c4d6615ddbb4aec0ea87d770214b26f7 *inst/doc/g_questions.html
f55f8b9f20dbc990c1ba5e94db47a2d8 *inst/doc/g_questions.html
427a5e0e1922bf1f26ffcf145b0f2514 *man/abstract.Rd
fd9e9ce2d1945ebda1a16405a88dc8e3 *man/aldex.cor.Rd
2f058dcf3c697dc7d60c76b6b76c4efc *man/aldex2propr.Rd
00e6f82dab49c508e8c49354e1b8acec *man/alphaTheta.Rd
7d34e580ea2d9b15371aa6ec33e165e6 *man/alphaThetaW_old.Rd
450a72151035e209b023042a4f435b74 *man/alphaTheta_old.Rd
0c9bfc7f79689f3fb43e148041b2503e *man/calculateFDR.Rd
Expand Down Expand Up @@ -96,14 +95,14 @@ adf5f41eb25fa3785dedd7cdfec76edd *man/ratios.Rd
43e8c454e137e528bf84a0e9f28f5b41 *man/top.counts.Rd
0b28506628ff9d62bee5a84c53009e83 *man/top.lr.Rd
c0a11039e8eff8328a19974bb39ea3a1 *man/visualize.Rd
5901363a543a0f4f1ab70dcfd1f9a4ac *src/RcppExports.cpp
6a48e43a015b474b60fbefb08bc4b645 *src/RcppExports.cpp
f42bb8afcb1f62352250c19656b9b656 *src/backend.cpp
d1b16bccebee797475a8dab1a378e9f4 *src/backend.h
6037eb80dc92132bc722f0959507031b *src/deprecated.cpp
33a5b02eae050f4fd5722e193f6ef63e *src/lr2propr.cpp
f2623c1f1c9fb4e950f715d39e5ea2d2 *src/theta.cpp
d369ed6f51c48cba415fe5fb03b22a5e *src/theta.cpp
38a416384180a93d31020bdffb37ccee *tests/testthat.R
bc3761cef956a660b05c57d6f854e9bf *tests/testthat/test-Fstat.R
67479128f5b86b641cbe9411a1ac24d4 *tests/testthat/test-Fstat.R
aeec9e5fda6a0115de5ef741b8ef1e3b *tests/testthat/test-aldex2propr.R
5f19f9636cdc9a9787c948b3d906fd9a *tests/testthat/test-backend.R
9dbd69d7466a4f768aaa432210aa1260 *tests/testthat/test-half2mat.R
Expand All @@ -114,10 +113,10 @@ d501a51b8d4df7c61ebae287eedf6a6f *tests/testthat/test-perb.R
2c5b021d73e71e87715e7dbbfb57ea28 *tests/testthat/test-phis.R
7329ca8ef8bde680bafc57cd14605088 *tests/testthat/test-phit.R
eeed7136f4a12f5a4f8afdbaa126f5fc *tests/testthat/test-prop2prob.R
341922568275e93771c278968becb7e2 *tests/testthat/test-propd.R
2ddaebe794a26a9ecce3c938b0ab13b7 *tests/testthat/test-propd.R
9f9b3f12ab7ae78bfda8f0271fc43f34 *tests/testthat/test-ratios.R
fee153a618e9faee5adfde6530322eb1 *tests/testthat/test-simplify.R
42979780d71cd5f153f57f7c9612c491 *tests/testthat/test-theta.R
e8363c9012dd6461c783fe69cddc8f27 *tests/testthat/test-theta.R
402488ed5ba1db09ff73ad27048a7237 *vignettes/a_introduction.Rmd
d8d1dd725e2aab656a24cc08501182a8 *vignettes/b_visualization.Rmd
9de81db8ce7fa892d22b2fd894c19a6c *vignettes/c_indexing.Rmd
Expand Down
34 changes: 34 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
## propr 3.5.1
---------------------
* Update CITATION file and README

## propr 3.5.0
---------------------
* Update alpha-transformation routine
* Update `lrm` C++ code
* Clone `Yfull` and set to power of alpha
* Add argument `Wfull` for complete weights (and check)
* Update calls to pass `Wfull` if provided
* Implement new non-weighted alpha-transformed means
* Implement new weighted alpha-transformed means
* Revise alpha-based unit tests
* Update `lrv` C++ code
* Clone `Yfull` and set to power of alpha
* Add argument `Wfull` for complete weights (and check)
* Update calls to pass `Wfull` if provided
* Implement new non-weighed alpha-transformed variances
* Implement new weighted alpha-transformed variances
* Revise alpha-based unit tests
* Remove `lrz` function

## propr 3.2.0
---------------------
* Prepare alpha-transformation routine for update
* Update `lrm` C++ code
* Add argument `a` and prepare code for alpha-based lrm
* Add argument `Yfull` for complete data (and check)
* Update calls to pass `Yfull` if provided
* Update `lrv` C++ code
* Add argument `Yfull` for complete data (and check)
* Update calls to pass `Yfull` if provided

## propr 3.1.9
---------------------
* Update C++ code to use `&&` and `||` instead of `&` and `|`
Expand Down
12 changes: 4 additions & 8 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,15 @@ wtvRcpp <- function(x, w) {
.Call(`_propr_wtvRcpp`, x, w)
}

lrm <- function(X, W, weighted = FALSE) {
.Call(`_propr_lrm`, X, W, weighted)
lrm <- function(Y, W, weighted = FALSE, a = NA_real_, Yfull = matrix(1, 1), Wfull = matrix(1, 1)) {
.Call(`_propr_lrm`, Y, W, weighted, a, Yfull, Wfull)
}

lrv <- function(Y, W, weighted = FALSE, a = NA_real_) {
.Call(`_propr_lrv`, Y, W, weighted, a)
lrv <- function(Y, W, weighted = FALSE, a = NA_real_, Yfull = matrix(1, 1), Wfull = matrix(1, 1)) {
.Call(`_propr_lrv`, Y, W, weighted, a, Yfull, Wfull)
}

omega <- function(X, W) {
.Call(`_propr_omega`, X, W)
}

lrz <- function(Y, W, Z, weighted = FALSE, a = NA_real_) {
.Call(`_propr_lrz`, Y, W, Z, weighted, a)
}

107 changes: 51 additions & 56 deletions R/deprecated2.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,21 @@ alphaTheta_old <- function(counts, group, alpha){
n1=length(cere)
n2=length(cort)

lrvMa=function(x,y,a){
N=length(x)
s=sum((x/mean(x)-y/mean(y))^2)/(a^2*(N-1))
return(s)
lrva=function(group,a,x,y){

N=length(group)
lrv=sum(((x[group]-mean(x[group]))/mean(x)-(y[group]-mean(y[group]))/mean(y))^2)
lrv=lrv/((N-1)*a^2)
return(lrv)
}

lrma=function(group,a,x,y){

m=mean(x[group]/mean(x)- y[group]/mean(y))
gr2=setdiff(c(1:length(x)),group)
C=mean(x[group]-y[group])+mean(x[gr2]-y[gr2])
lrm=(C/2+m)/a
return(lrm)
}

a=alpha
Expand All @@ -168,11 +179,11 @@ alphaTheta_old <- function(counts, group, alpha){

ast[i,1]=as.integer(j)
ast[i,2]=as.integer(k)
ast[i,4]=lrvMa(Ma[,j],Ma[,k],a)
ast[i,5]=lrvMa(Ma[cere,j],Ma[cere,k],a)
ast[i,6]=lrvMa(Ma[cort,j],Ma[cort,k],a)
ast[i,7]=mean(Ma[cere,j]-Ma[cere,k])/a
ast[i,8]=mean(Ma[cort,j]-Ma[cort,k])/a
ast[i,4]=lrva(which(group1 | group2), a, Ma[,j], Ma[,k])
ast[i,5]=lrva(which(group1), a, Ma[,j], Ma[,k])
ast[i,6]=lrva(which(group2), a, Ma[,j], Ma[,k])
ast[i,7]=lrma(which(group1), a, Ma[,j], Ma[,k])
ast[i,8]=lrma(which(group2), a, Ma[,j], Ma[,k])
ast[i,3]=((n1-1)*ast[i,5]+(n2-1)*ast[i,6])/((n1+n2-1)*ast[i,4])
i=i+1
}
Expand Down Expand Up @@ -200,22 +211,37 @@ alphaThetaW_old <- function(counts, group, alpha, weights){
n1=length(cere)
n2=length(cort)

lrvMaw=function(x,y,a,W){
n=sum(W)
s=sum(W^2)
lrvaw=function(group,a,x,y,W){

n=sum(W[group])
s=sum(W[group]^2)
p=n-s/n
N=length(x)
w=W/n
s=sum(W*(x/(N*mean(w*x))-y/(N*mean(w*y)))^2)/(p*a^2)
return(s)
w=W[group]/n

lrv=sum(W[group]*((x[group]-sum(w*x[group]))/(sum(W*x)/sum(W))-(y[group]-sum(w*y[group]))/(sum(W*y)/sum(W)))^2)
lrv=lrv/(p*a^2)
return(lrv)
}

lrmaw=function(group,a,x,y,W){

w=W[group]/sum(W[group])
m=sum(w*(x[group]/(sum(W*x)/sum(W))-y[group]/(sum(W*y)/sum(W))))

gr2=setdiff(c(1:length(x)),group)
w2=W[gr2]/sum(W[gr2])
C=sum(w*(x[group]-y[group]))+sum(w2*(x[gr2]-y[gr2]))

lrm=(C/2+m)/a
return(lrm)
}

a=alpha
Ma=counts^a
llt=ncol(counts)*(ncol(counts)-1)/2
modwa=c(1:llt)
stwa=matrix(0,llt,2)
colnames(stwa)=c("lrv","theta")
stwa=matrix(0,llt,6)
colnames(stwa)=c("lrv","theta", "awlrv1", "awlrv2", "awlrm1", "awlrm2")
i=0
for (j in 2:dim(Ma)[2]){
for (k in 1:(j-1)){
Expand All @@ -231,10 +257,14 @@ alphaThetaW_old <- function(counts, group, alpha, weights){
n2=sum(W[cort])
s2=sum(W[cort]^2)
p2=n2-s2/n2
swxy1=lrvMaw(Ma[cere,j],Ma[cere,k],a,W[cere])
swxy2=lrvMaw(Ma[cort,j],Ma[cort,k],a,W[cort])
stwa[i,"lrv"]=lrvMaw(Ma[,j],Ma[,k],a,W)
swxy1=lrvaw(which(group1), a, Ma[,j], Ma[,k], W)
swxy2=lrvaw(which(group2), a, Ma[,j], Ma[,k], W)
stwa[i,"lrv"]=lrvaw(which(group1 | group2), a, Ma[,j], Ma[,k], W)
stwa[i,"theta"]=(p1*swxy1+p2*swxy2)/(p*stwa[i,"lrv"])
stwa[i,"awlrv1"] = swxy1
stwa[i,"awlrv2"] = swxy2
stwa[i,"awlrm1"]=lrmaw(which(group1), a, Ma[,j], Ma[,k], W)
stwa[i,"awlrm2"]=lrmaw(which(group2), a, Ma[,j], Ma[,k], W)
}
}

Expand Down Expand Up @@ -392,38 +422,3 @@ calculateFDR <- function(theta, ptheta, cutoff = seq(.6, .9, .1)){

return(out)
}

#' Calculate alpha Theta
#'
#' Calculate differential proportionality measure, theta,
#' using the Box-Cox transformation method.
#'
#' @inheritParams propd
alphaTheta <- function(counts, group, alpha){

ct <- as.matrix(counts)
lrv <- lrv(ct, ct, a = alpha)

if(length(unique(group)) != 2) stop("Please use two groups.")
if(length(group) != nrow(counts)) stop("Too many or too few group labels.")
group1 <- group == unique(group)[1]
group2 <- group == unique(group)[2]

lrv1 <- lrv(ct[group1,], ct[group1,], a = alpha)
lrv2 <- lrv(ct[group2,], ct[group2,], a = alpha)
n1 <- sum(group1)
n2 <- sum(group2)

theta <- ((n1-1) * lrv1 + (n2-1) * lrv2) / ((n1+n2-1) * lrv)

labels <- labRcpp(ncol(counts))
return(
data.frame(
"Partner" = labels[[1]],
"Pair" = labels[[2]],
"theta" = theta,
"lrv" = lrv,
"lrv1" = lrv1,
"lrv2" = lrv2
))
}
10 changes: 5 additions & 5 deletions R/theta.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ calculateTheta <- function(counts, group, alpha, lrv = NA, only = "all",
}

# Calculate weighted and/or alpha-transformed LRVs -- W not used if weighted = FALSE
if(firstpass) lrv <- lrv(ct, W, weighted, alpha)
lrv1 <- lrv(ct[group1,], W[group1,], weighted, alpha)
lrv2 <- lrv(ct[group2,], W[group2,], weighted, alpha)
if(firstpass) lrv <- lrv(ct, W, weighted, alpha, ct, W)
lrv1 <- lrv(ct[group1,], W[group1,], weighted, alpha, ct, W)
lrv2 <- lrv(ct[group2,], W[group2,], weighted, alpha, ct, W)

# Calculate LRM (replacing 0s if alpha is used) -- LRM not affected by alpha
if(only == "all"){
Expand All @@ -71,8 +71,8 @@ calculateTheta <- function(counts, group, alpha, lrv = NA, only = "all",
ct[ct == 0] <- 1 # ct not used again in scope
}

lrm1 <- lrm(ct[group1,], W[group1,], weighted)
lrm2 <- lrm(ct[group2,], W[group2,], weighted)
lrm1 <- lrm(ct[group1,], W[group1,], weighted, alpha, ct, W)
lrm2 <- lrm(ct[group2,], W[group2,], weighted, alpha, ct, W)
}

# Replace NaN thetas (from VLR = 0 or VLR = NaN) with 1
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ library(propr)
Further reading
---------------

To learn more about proportionality, please see the vignettes and other relevant literature.
To learn more about proportionality, please see the vignettes and relevant literature.

``` r
citation("propr")
Expand All @@ -36,9 +36,10 @@ citation("propr")
## Compositional Data Analysis Workshop; available under bioRxiv
## 134536: doi:10.1101/134536
##
## Quinn T, Erb I, Richardson MF, Crowley T (2017) Understanding
## sequencing data as compositions: an outlook and review. bioRxiv:
## doi:10.1101/206425
## Quinn T, Erb I, Richardson MF, Crowley T (2018) Understanding
## sequencing data as compositions: an outlook and review.
## Bioinformatics. Advanced Access Publication:
## doi:10.1093/bioinformatics/bty175
##
## Lovell D, Pawlowsky-Glahn V, Egozcue JJ, Marguerat S, Bahler J
## (2015) Proportionality: A Valid Alternative to Correlation for
Expand Down
10 changes: 5 additions & 5 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ citEntry(entry = "Article",
as.person("Ionas Erb"),
as.person("Mark F. Richardson"),
as.person("Tamsyn Crowley")),
journal = "bioRxiv",
year = "2017",
journal = "Bioinformatics",
year = "2018",

textVersion =
paste("Quinn T, Erb I, Richardson MF, Crowley T (2017)",
paste("Quinn T, Erb I, Richardson MF, Crowley T (2018)",
"Understanding sequencing data as compositions:",
"an outlook and review.",
"bioRxiv: doi:10.1101/206425")
"an outlook and review. Bioinformatics.",
"Advanced Access Publication: doi:10.1093/bioinformatics/bty175")
)

citEntry(entry = "Article",
Expand Down

0 comments on commit 027651e

Please sign in to comment.