-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3f25964
Showing
11 changed files
with
766 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package: pRepDesigns | ||
Type: Package | ||
Title: Partially Replicated (p-Rep) Designs | ||
Version: 1.0.0 | ||
Authors@R: c(person( "Vinaykumar", "L.N.", email = "vinaymandya123@gmail.com" , role = c( "aut","cre")),person("Cini", "Varghese", email = "cini2204@gmail.com", role = c( "aut","ctb")),person("Mohd", "Harun", email = "harun.agribhu@gmail.com" , role = c( "aut","ctb")),person("Ashutosh","Dalal", email = "ashutosh.dalal97@gmail.com", role =c("aut","ctb")),person("Sayantani", "Karmakar", email = "sayantanikarmakar20@gmail.com", role =c( "aut","ctb")),person("Vinayaka", email = " vinayaka.b3vs@gmail.com", role =c( "aut","ctb"))) | ||
Maintainer: Vinaykumar L.N. <vinaymandya123@gmail.com> | ||
Description: Early generation breeding trials are to be conducted in multiple environments where it may not be possible to replicate all the lines in each environment due to scarcity of resources. For such situations, partially replicated (p-Rep) designs have wide application potential as only a proportion of the test lines are replicated at each environment. A collection of several utility functions related to p-Rep designs have been developed. Here, the package contains four functions for a complete stepwise analytical study of these designs. Three functions pRep1(), pRep2() and pRep3() are used to generate three new series of p-Rep designs and also compute canonical efficiency factors, variance factors between associates and average variance factors of these designs. A fourth function NCEV() is used to generate incidence matrix (N), information matrix (C), canonical efficiency factor (E) and average variance factor (V). This function is general in nature and can be used for studying the characterization properties of any block design.A construction procedure for p-Rep designs was given by Williams et al.(2011)<doi:10.1002/bimj.201000102> which was tidious and time consuming. Here, in this package, three different methods have been given to generate p-Rep designs easily. | ||
Suggests: MASS | ||
License: GPL (>= 2) | ||
Encoding: UTF-8 | ||
LazyData: false | ||
Repository: CRAN | ||
RoxygenNote: 7.1.2 | ||
NeedsCompilation: no | ||
Packaged: 2022-09-01 05:40:32 UTC; Vinaykumar LN | ||
Author: Vinaykumar L.N. [aut, cre], | ||
Cini Varghese [aut, ctb], | ||
Mohd Harun [aut, ctb], | ||
Ashutosh Dalal [aut, ctb], | ||
Sayantani Karmakar [aut, ctb], | ||
Vinayaka [aut, ctb] | ||
Date/Publication: 2022-09-01 15:30:02 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
7da73ad5f2b94e6083d4d3b14c9fefb7 *DESCRIPTION | ||
7c54802a278c089ccbb4e5c32c823e14 *NAMESPACE | ||
1655c81b862f38971f5ec25234bd3f6a *R/NCEV.R | ||
67f68d78d6f8b6f9a6aa4bc5586ebf90 *R/pRep1.R | ||
193b8892b4caf47357db8badc737f6e8 *R/pRep2.R | ||
d85f761a5b3dfbe818c7a22deea277e0 *R/pRep3.R | ||
1a698678de780595d01ab5ba847723ae *man/NCEV.Rd | ||
e14560154cad98474d5061d554299116 *man/pRep1.Rd | ||
f4e9939b35e7aa9b085ded88fac6eb8a *man/pRep2.Rd | ||
7517274fcbfc544e933851dfd0403b2c *man/pRep3.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(NCEV) | ||
export(pRep1) | ||
export(pRep2) | ||
export(pRep3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
###################################################### | ||
#' Incidence Matrix, Information Matrix, Canonical efficiency factor, Variance between associates and average variance | ||
#' | ||
#' @param design p-rep design in matrix form considering rows as blocks | ||
#' | ||
#'@description This function generates incidence matrix, information matrix, canonical efficiency factor,variance factor between associates and average variance for the input design | ||
#' @return This function generates incidence matrix, information matrix, canonical efficiency factor, variance factor between associates and average variance factor for the input design | ||
#' @export | ||
#' | ||
#' @examples | ||
#'library(pRepDesigns) | ||
#'design=matrix(1:9, nrow = 3, ncol = 3) | ||
#'NCEV(design) | ||
#'@references | ||
#'Williams E, Piepho HP, Whitaker D (2011)<https://doi.org/10.1002/bimj.201000102> | ||
###################################################### | ||
NCEV=function(design){ | ||
v = max(design) | ||
b = nrow(design) | ||
k = ncol(design) | ||
N = matrix(0, v, b) | ||
N_matrix=function(design) | ||
{ | ||
|
||
for (i in 1:b) { | ||
for (j in 1:k) { | ||
N[design[i, j], i] = N[design[i, j], i] + 1 | ||
} | ||
} | ||
N | ||
} | ||
N_mat=N_matrix(design) | ||
########################################################### | ||
C_matrix=function(N_mat){ | ||
v1=nrow(N_mat) | ||
b1=ncol(N_mat) | ||
r=3 | ||
K=diag(colSums(N_mat), b1, b1) | ||
R=diag(rowSums(N_mat), v1, v1) | ||
kvec=colSums(N_mat) | ||
Kinv = diag(1/kvec, nrow = b1, ncol = b1) | ||
C = R - N_mat %*% Kinv %*% t(N_mat) | ||
C | ||
} | ||
C_mat<-C_matrix(N_mat) | ||
########################################################## | ||
C_Efficiency=function(C_mat){ | ||
E=eigen(C_mat, only.values = T) | ||
r=3 | ||
E1=unlist(E) | ||
E_positive=E1[E1>=0.000000001] | ||
n=length(E_positive) | ||
C_Efficiency=n/(r*sum(c(1/E_positive))) | ||
C_Efficiency | ||
} | ||
C_E=C_Efficiency(C_mat) | ||
############################################################## | ||
p_matrix=matrix(,nrow=0,ncol=v) | ||
i=1 | ||
j=1 | ||
while(i<=(choose(v,2))){ | ||
j=i+1 | ||
while(j<=v){ | ||
p1<-matrix(0,nrow=1,ncol=v) | ||
p1[i]<-1 | ||
p1[j]<--1 | ||
p_matrix<-rbind(p_matrix,p1) | ||
j=j+1 | ||
} | ||
i=i+1 | ||
} | ||
p_matrix | ||
p_invC_Pprme=(p_matrix)%*%MASS::ginv(C_mat)%*%t(p_matrix) | ||
var<-diag(p_invC_Pprme) | ||
var1<-round(var,digits=4) | ||
var2<-unique(var1) | ||
Average_var<-mean(var) | ||
########################################################### | ||
results=list( "Incidence matrix"=N_mat, "C-matrix"=round(C_mat, 4), "Canonical Efficiency factor"= round(C_E,4), "Variance factor b/w associates"=var2,"Average variance factor"=round(Average_var,4)) | ||
print(results) | ||
} | ||
################################################## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
################################### | ||
#' First series of p-rep designs | ||
#' | ||
#' @param v Total number of treatments or breeding lines or entries | ||
#' @param m positive integer (>=1) | ||
#' @param s positive integer (>=3) | ||
#'@description This function generates first series of p-rep designs for given values of v, m and s. The input should satisfy the condition v=2*m*s*(s-1), m>=1 and s>=3. | ||
#' @return | ||
#' This function generates p-rep designs with parameters: | ||
#' | ||
#' v = 2ms(s-1) : number of treatments, | ||
#' | ||
#' b_1 = 2(s-1) : first set of blocks of size k_1 = ms, | ||
#' | ||
#' b_2 = 2s : second set of blocks of size k_2 = 2m(s-1) and | ||
#' | ||
#' r = 3 : number of replications. | ||
#' | ||
#' e = 2 : number of environments, | ||
#' | ||
#' This function also generates incidence matrix, information matrix, canonical efficiency factor and average variance factor of the generated p-rep design. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' library(pRepDesigns) | ||
#' pRep1(24, 2, 3) | ||
#' | ||
#'@references | ||
#'Williams E, Piepho HP, Whitaker D (2011)<https://doi.org/10.1002/bimj.201000102> | ||
######################################################## | ||
################################################ | ||
pRep1<-function(v,m,s){ | ||
if(m>=1 && s>=3 && v==2*m*s*(s-1)){ | ||
v=2*m*s*(s-1) | ||
b1=2*(s-1) | ||
b2=2*s | ||
r=3 | ||
k1=m*s | ||
k2=2*m*(s-1) | ||
e=2 | ||
vv=1 | ||
y=c() | ||
while(vv<=(v)){ | ||
x=c(vv) | ||
y=c(y, x) | ||
vv=vv+1 | ||
} | ||
y=matrix(y, nrow = s, byrow= F, ncol = 2*m*(s-1)) | ||
y | ||
###################################### | ||
z=c() | ||
while(vv<=v){ | ||
x=c(vv) | ||
z=c(z, x) | ||
vv=vv+1 | ||
} | ||
z=matrix(y, nrow = 2*(s-1), byrow= T, ncol = m*s) | ||
z | ||
##################################### | ||
h<-nrow(z)/2 | ||
cz<-ncol(z) | ||
xx<-z[1:h,] | ||
blank<-matrix(,nrow=nrow(xx),ncol=(ncol(y)-ncol(xx))) | ||
a<-cbind(xx,blank) | ||
final1<-rbind(a,y) | ||
row.names(final1)<-c(1:nrow(final1)) | ||
ss=1 | ||
while(ss<=nrow(final1)){ | ||
rownames(final1)[ss] <- paste("block",as.character(ss),sep="") | ||
ss=ss+1 | ||
} | ||
######################################## | ||
xy<-z[(1+nrow(z)/2):nrow(z),] | ||
blank<-matrix(,nrow=nrow(xy),ncol=(ncol(y)-ncol(xy))) | ||
b<-cbind(xy,blank) | ||
final2<-rbind(b,y) | ||
row.names(final2)<-c(1:nrow(final2)) | ||
ss=nrow(final1)+1 | ||
sp=1 | ||
while(ss<=(2*(nrow(final1)))){ | ||
rownames(final2)[sp] <- paste("block",as.character(ss),sep="") | ||
sp=sp+1 | ||
ss=ss+1 | ||
} | ||
####################################### | ||
design<-rbind(final1,final2) | ||
design[is.na(design)]=0 | ||
####################################### | ||
N_matrix=function(design) | ||
{ | ||
v = max(design) | ||
b = nrow(design) | ||
k = ncol(design) | ||
N = matrix(0, v, b) | ||
for (i in 1:b) { | ||
for (j in 1:k) { | ||
N[design[i, j], i] = N[design[i, j], i] + 1 | ||
} | ||
} | ||
N | ||
} | ||
N_mat=N_matrix(design) | ||
########################################################### | ||
C_matrix=function(N_mat){ | ||
v=nrow(N_mat) | ||
b=ncol(N_mat) | ||
r=3 | ||
K=diag(colSums(N_mat), b, b) | ||
R=diag(rowSums(N_mat), v, v) | ||
kvec=colSums(N_mat) | ||
Kinv = diag(1/kvec, nrow = b, ncol = b) | ||
C = R - N_mat %*% Kinv %*% t(N_mat) | ||
C | ||
} | ||
C_mat<-C_matrix(N_mat) | ||
########################################################## | ||
C_Efficiency=function(C_mat){ | ||
E=eigen(C_mat, only.values = T) | ||
r=3 | ||
E1=unlist(E) | ||
E_positive=E1[E1>=0.000000001] | ||
n=length(E_positive) | ||
CE=n/(r*sum(c(1/E_positive))) | ||
} | ||
C_E=C_Efficiency(C_mat) | ||
############################################################## | ||
nc=ncol(C_mat) | ||
p_matrix=matrix(,nrow=0,ncol=v) | ||
i=1 | ||
j=1 | ||
while(i<=(choose(v,2))){ | ||
j=i+1 | ||
while(j<=v){ | ||
p1<-matrix(0,nrow=1,ncol=v) | ||
p1[i]<-1 | ||
p1[j]<--1 | ||
p_matrix<-rbind(p_matrix,p1) | ||
j=j+1 | ||
} | ||
i=i+1 | ||
} | ||
p_matrix | ||
p_invC_Pprme=(p_matrix)%*%MASS::ginv(C_mat)%*%t(p_matrix) | ||
var<-diag(p_invC_Pprme) | ||
var1<-round(var, digits=4) | ||
var2<-unique(var1) | ||
Average_var<-mean(var) | ||
########################################################### | ||
A1=c("Number of treatments","First set of blocks","Second set of blocks","Number of replications","Block size of b1","Block size of b2","Number of environments") | ||
A2=c("v", "b1", "b2","r", "k1", "k2", "e") | ||
A3=c(v, b1, b2, r, k1, k2, e) | ||
A=cbind(A1, A2, A3) | ||
prmatrix(A,rowlab=,collab=rep("",ncol(A)),quote=FALSE,na.print="") | ||
message("\n") | ||
########################################################## | ||
message("p-rep design") | ||
message("\n","Environment_1 of p-rep design") | ||
prmatrix(final1,rowlab=,collab=rep("",ncol(final1)),quote=FALSE,na.print="") | ||
message(c("\n","Environment_2 of p-rep design")) | ||
prmatrix(final2,rowlab=,collab=rep("",ncol(final2)),quote=FALSE,na.print="") | ||
message("\n") | ||
############################################################# | ||
print(c("Canonical Efficiency factor", round(C_E,4)),quote=F) | ||
############################################################# | ||
B1<-c("variance factor between first associates","variance factor between second associates","variance factor between third associates","variance factor between fourth associates") | ||
B2<-c(var2[1],var2[2],var2[3],var2[4]) | ||
if(m==1){ | ||
B1<-B1[1:3] | ||
B2<-B2[1:3] | ||
} | ||
B<-cbind(B1,B2) | ||
prmatrix(B,rowlab=,collab=rep("",ncol(B)),quote=FALSE,na.print="") | ||
message("\n") | ||
############################################################### | ||
print(c("Average variance factor", round(Average_var,4)),quote=F) | ||
################################################################# | ||
} else { | ||
message("Please enter v(=2*m*s*(s-1), where m>=2 and s>=3)") | ||
} | ||
} | ||
################################################################################ | ||
#pRep1(12, 1, 3) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.