#' Read a \emph{.genes.raw} file
#'
#' Read a \emph{.genes.raw} file generated by
#' \link[MAGMA.Celltyping]{map_snps_to_genes}
#' as a \link[data.table]{data.table}.
#' @param path Path to a MAGMA \emph{.genes.raw} file.
#' @param verbose Print messages.
#' @returns \link[data.table]{data.table}
#'
#' @keywords internal
#' @importFrom stringr str_split
#' @importFrom data.table data.table rbindlist setnames :=
#' @importFrom dplyr relocate
read_magma_genes_raw <- function(path,
verbose = TRUE){
messager("Importing genes.raw file.",v=verbose)
entrez <- hgnc_symbol <- NULL;
l <- readLines(path)[-seq_len(2)]
l <- stringr::str_split(l," ")
dt <- data.table::rbindlist(
lapply(l, function(x) data.table::data.table(t(x))),
fill = TRUE
)
data.table::setnames(dt,
old = c("V1","V2","V3","V4"),
new = c("entrez","chrom","start","end"))
dt[,entrez:=as.character(entrez)]
dt <- merge(
x = dt,
y = MAGMA.Celltyping::hgnc2entrez_orthogene,
by = "entrez"
)
dt <- dplyr::relocate(dt,hgnc_symbol, .after = "entrez")
return(dt)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.