R/zzz.R

Defines functions mrnet_impl clr_impl aracne_impl mi_all mi_cross mi_single

# Copyright 2010-2020 Gabriele Sales <gabriele.sales@unipd.it>
#
#
# This file is part of parmigene.
#
# knnmi is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License
# version 3 as published by the Free Software Foundation.
#
# knnmi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with parmigene. If not, see <http://www.gnu.org/licenses/>.

mi_single <- function(x, y, k, noise) {
  .C(C_mi_single,
     as.double(x),
     as.double(y),
     as.integer(length(x)),
     as.integer(k),
     as.double(noise),
     res = double(1),
     PACKAGE = "parmigene")$res
}

mi_cross <- function(xs, ys, k, noise) {
  h1 <- nrow(xs)
  h2 <- nrow(ys)
  w  <- ncol(xs)

  res <-
    .C(C_mi_cross,
       as.double(t(xs)),
       as.integer(h1),
       as.double(t(ys)),
       as.integer(h2),
       as.integer(w),
       as.integer(k),
       as.double(noise),
       res = double(h1*h2),
       PACKAGE = "parmigene")$res

  m <- t(matrix(res, nrow=h2))
  rownames(m) <- rownames(xs)
  colnames(m) <- rownames(ys)
  m
}

mi_all <- function(xs, k, noise) {
  h <- nrow(xs)
  w <- ncol(xs)

  res <-
    .C(C_mi_all,
       as.double(t(xs)),
       as.integer(h),
       as.integer(w),
       as.integer(k),
       as.double(noise),
       res = double(h*h),
       PACKAGE = "parmigene")$res

  m <- matrix(res, nrow=h)
  colnames(m) <- rownames(xs)
  rownames(m) <- rownames(xs)
  m
}

aracne_impl<- function(mis, n, eps, eta) {
  res <-
    .C(C_aracne,
       as.double(t(mis)),
       as.integer(n),
       as.double(eps),
       as.double(eta),
       res=double(n*n),
       PACKAGE = "parmigene")$res

  m <- matrix(res, nrow=n)
  colnames(m) <- rownames(mis)
  rownames(m) <- rownames(mis)
  m
}

clr_impl <- function(mis, n) {
  res <-
    .C(C_clr,
       as.double(t(mis)),
       as.integer(n),
       res = double(n*n),
       PACKAGE = "parmigene")$res

  m <- matrix(res, nrow=n)
  colnames(m) <- rownames(mis)
  rownames(m) <- rownames(mis)
  m
}

mrnet_impl <- function(mis, n) {
    res <-
      .C(C_mrnet,
         as.double(t(mis)),
         as.integer(n),
         res = double(n*n),
         PACKAGE = "parmigene")$res

  m <- matrix(res, nrow=n)
  colnames(m) <- rownames(mis)
  rownames(m) <- rownames(mis)
  m
}

Try the parmigene package in your browser

Any scripts or data that you put into this service are public.

parmigene documentation built on Aug. 3, 2020, 5:13 p.m.