Commit 0b2a16e7 authored by houyun's avatar houyun
Browse files

can grouped data by regex

parent 2a6df41c
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -127,14 +127,14 @@ correlate <- function(x,
                                      ...))
    }
  } else {
    if (length(group) != nrow(x)) {
      stop("group should have same length as rows of x.", call. = FALSE)
    }
    # if (length(group) != nrow(x)) {
    #   stop("group should have same length as rows of x.", call. = FALSE)
    # }
    x <- tryCatch(as.data.frame(x), error = function(e) as.data.frame(as.matrix(x)))
    x <- split(x, group)
    x <- split_by_group(x, group)
    if (!is.null(y)) {
      y <- tryCatch(as.data.frame(y), error = function(e) as.data.frame(as.matrix(y)))
      y <- split(y, group)
      y <- split_by_group(y, group)
    } else {
      y <- rep_len(list(NULL), length(x))
    }
+7 −7
Original line number Diff line number Diff line
@@ -101,17 +101,17 @@ mantel_test <- function(spec,
  }

  if(!is.null(group)) {
    ## TODO: set group by regex
    if(length(group) != nrow(spec)) {
      stop("Length of 'group' and rows of 'spec' must be same.", call. = FALSE)
    }
    # ## TODO: set group by regex
    # if(length(group) != nrow(spec)) {
    #   stop("Length of 'group' and rows of 'spec' must be same.", call. = FALSE)
    # }

    spec <- split(spec, group, drop = FALSE)
    env <- split(env, group, drop = FALSE)
    spec <- split_by_group(spec, group)
    env <- split_by_group(env, group)

    if(mantel_fun == "mantel.partial") {
      if(is.data.frame(env_ctrl)) {
        env_ctrl <- split(env_ctrl, group, drop = FALSE)
        env_ctrl <- split_by_group(env_ctrl, group)
      }
      if(is.list(env_ctrl)) {
        env_ctrl <- env_ctrl[names(spec)]