R/eMIRNA.Predict.R

#' eMIRNA Function for calculating Features from provided filtered sequences.
#'
#' \code{eMIRNA.Predict} Returns a list of sequence names that have been predicted
#' as miRNAs by the SVM classifier.
#'
#' @param model Path to .rds file with SVM classifier or corresponding R object.
#'
#' @param features Path to .csv or R object with calculated Features from Candidate
#' sequences
#'  \code{file}.
#'
#' @param prefix Desired name for Features .txt file output.
#'
#' @examples
#' eMIRNA.Predict(SVM, Candidates, "Candidates")
#'
#' @export



eMIRNA.Predict <- function(model, features, prefix){
  pred <- predict(model, newdata= features)

  index <- which(pred == "miRNA")

  pred <- as.data.frame(rownames(features[index,]))
  colnames(pred) <- "Predicted_miRNAs"

  setwd("~/")
  Dir0 <- "eMIRNA"
  dir.create(file.path(Dir0), showWarnings=FALSE)
  Dir <- "Prediction_Results"
  setwd("~/eMIRNA/")
  dir.create(file.path(Dir), showWarnings = FALSE)
  workdir <- "~/eMIRNA/Prediction_Results/"
  setwd(workdir)

  pred.path <- paste0(workdir, prefix, ".txt")
  write.table(pred, pred.path, quote=F, col.names=F, row.names=F)

  return(pred)

}
emarmolsanchez/eMIRNA_Rmodules documentation built on May 14, 2019, 5 a.m.