R/read_smap.R

Defines functions read_smap

Documented in read_smap

#' Read .smap file
#'
#' Read structural variants in .smap file.
#'
read_smap <- function(file, sort = FALSE) {

	a <- tbl_df(read.table(file, stringsAsFactors = FALSE))

	if (ncol(a) >= 17) {
		colnames(a) <- c("smapID", "qryID", "refID1", "refID2", "qryStart", "qryEnd",
				"refStart", "refEnd", "confidence", "type", "xmapID1", "xmapID2",
				"linkID", "qryStartIdx", "qryEndIdx", "refStartIdx", "refEndIdx")
	} else if (ncol(a) >= 13) {
		colnames(a) <- c("smapID", "qryID", "refID1", "refID2", "qryStart", "qryEnd",
				"refStart", "refEnd", "orientation", "confidence",
				"type", "xmapID1", "xmapID2")
	} else {
		colnames(a) <- c("smapID", "qryID", "refID1", "refID2", "qryStart", "qryEnd",
				"refStart", "refEnd", "confidence",
				"type", "xmapID1", "xmapID2")[1:ncol(a)]
	}

	if (sort) {
		a <- a %>% arrange(refID1, refID2, refStart, refEnd)
	}
	return(a)
}
yanlinlin82/Rbionano documentation built on Dec. 26, 2019, 7:37 a.m.