Patch the bug on aggregate when aggregating by samples
This commit is contained in:
@@ -12,6 +12,7 @@ aggregate.metabarcoding.data=function(x, by, FUN,...,
|
||||
default.layer=NULL,
|
||||
layers=NULL) {
|
||||
|
||||
|
||||
uniq.value = function(z) {
|
||||
|
||||
if (is.null(z) |
|
||||
@@ -57,11 +58,14 @@ aggregate.metabarcoding.data=function(x, by, FUN,...,
|
||||
|
||||
reads = x@reads
|
||||
|
||||
|
||||
if (MARGIN==1) {
|
||||
# prepare the aggrevation arguments for the read table
|
||||
# from the function arguments
|
||||
dotted = list(...)
|
||||
if (length(dotted) > 0)
|
||||
|
||||
|
||||
if (length(dotted) > 0)
|
||||
aggr.args = list(reads,by=by,FUN=FUN,...=dotted,simplify=FALSE)
|
||||
else
|
||||
aggr.args = list(reads,by=by,FUN=FUN,simplify=FALSE)
|
||||
@@ -130,14 +134,15 @@ aggregate.metabarcoding.data=function(x, by, FUN,...,
|
||||
# modalities to the last columns of the data.frame
|
||||
sagr = sagr[,c((ncat+1):(dim(sagr)[2]),1:ncat),drop=FALSE]
|
||||
larg = c(lapply(sagr,unlist),list(stringsAsFactors=FALSE))
|
||||
sagr = do.call(data.frame,larg)
|
||||
sagr = data.frame(do.call(data.frame,larg))
|
||||
|
||||
# set samples ids to the ids computed from modalities
|
||||
sagr$id=ids
|
||||
|
||||
rownames(sagr)=ids
|
||||
sagr$id=ids
|
||||
|
||||
# build the new metabarcoding data instance
|
||||
newdata = copy.metabarcoding.data(x,reads=ragr,samples=sagr)
|
||||
newdata = copy.metabarcoding.data(x,reads=ragr,samples=sagr,layers=la)
|
||||
|
||||
}
|
||||
else {
|
||||
|
Reference in New Issue
Block a user