R/correctedBed2AllInfo.R

Defines functions correctedBed2AllInfo

Documented in correctedBed2AllInfo

#' Make a "corrected" version of the All-Info file
#' after using IsoQuant to identify incorrect splice sites
#' @aliases bed2AllInfo
#' @description This function takes in a corrected bed file
#' that is generated after running IsoQuant, as well as the AllInfo
#' file that is the output of scisorseqr. It produces a new AllInfo
#' file with extra columns containing the original and corrected exon
#' and intron chains. Best use case is for Oxford Nanopore data which
#' can have errors in splice-site assignment
#' @seealso \code{\link{InfoPerLongRead}}
#' @seealso \link[IsoQuant]{https://github.com/ablab/IsoQuant}
#' @param bedPath Path to corrected bed file. Currently does not
#' support bed.gz
#' @param Path to AllInfo file. Currently supports only AllInfo_Incomplete.
#' Defaults to the file generated by the InfoPerLongRead() function
#' @param Path to the output.gz file. Defaults to the LongReadInfo folder and
#' generates a file named "AllInfo_IncompleteReads_corrected.gz".
#' @return A file in the AllInfo_Incomplete format with column 6 being the
#' corrected intron chain, column 9 being the corrected exon chain, and
#' additional columns 10 and 11 being the original intron and exon chains
#' respectively
#' @usage correctedBed2AllInfo(bedPath='Sample_sorted.corrected_reads.bed',
#'allInfo = "LongReadInfo/AllInfo_IncompleteReads_corrected.gz",
#'outFile = "LongReadInfo/AllInfo_IncompleteReads_corrected.gz")
#' @export

correctedBed2AllInfo <- function(bedPath, allInfo = "LongReadInfo/AllInfo_IncompleteReads_corrected.gz",
	outFile = "LongReadInfo/AllInfo_IncompleteReads_corrected.gz") {

  conversionScript <- system.file("bash", "bed12_toAllInfo.sh", package = "scisorseqr")

  if(!file.exists(bedPath)){stop(paste("ERROR:",bedPath,"not a regular file"))}
  if(!file.exists(allInfo)){stop(paste("ERROR:",allInfo,"not a regular file"))}

  print("Getting corrected barcoded reads in an All-Info format")
  runIt <- paste("bash", conversionScript, bedPath, allInfo, outFile)
  system(runIt)

}
noush-joglekar/scisorseqr documentation built on March 18, 2023, 8:06 p.m.