|
a |
|
b/R/SeekGtexOrgan.R |
|
|
1 |
#' Load and Process GTEX Phenotype Data to Retrieve Primary Site Counts |
|
|
2 |
#' |
|
|
3 |
#' This function reads the GTEX phenotype data from a specified path, renames its columns for better readability, |
|
|
4 |
#' and then returns a table of primary site counts. |
|
|
5 |
#' |
|
|
6 |
#' @param path The path to the GTEX phenotype data file. Default is "./download_data/GTEX_phenotype". |
|
|
7 |
#' |
|
|
8 |
#' @return A table representing the count of samples per primary site. |
|
|
9 |
#' @importFrom utils read.table |
|
|
10 |
#' @examples |
|
|
11 |
#' # Get the file path to the example data in the package |
|
|
12 |
#' path <- system.file("extdata", "GTEX_phenotype_test", package = "TransProR") |
|
|
13 |
#' # Call the `seek_gtex_organ` function with the path and print the result |
|
|
14 |
#' SeekGtexOrgan <- seek_gtex_organ(path = path) |
|
|
15 |
#' |
|
|
16 |
#' @export |
|
|
17 |
|
|
|
18 |
seek_gtex_organ <- function(path = "./download_data/GTEX_phenotype") { |
|
|
19 |
# Read GTEX phenotype data |
|
|
20 |
# gtex.phe <- data.table::fread(path, header = TRUE, sep = '\t', data.table = FALSE) |
|
|
21 |
|
|
|
22 |
gtex.phe <- utils::read.table(path, |
|
|
23 |
header = TRUE, |
|
|
24 |
sep = '\t', |
|
|
25 |
stringsAsFactors = FALSE, |
|
|
26 |
check.names = FALSE) |
|
|
27 |
|
|
|
28 |
rownames(gtex.phe) <- gtex.phe$Sample |
|
|
29 |
|
|
|
30 |
# Rename columns |
|
|
31 |
colnames(gtex.phe) <- c("Sample", "body_site_detail (SMTSD)", "primary_site", "gender", "patient", "cohort") |
|
|
32 |
|
|
|
33 |
# Create table of primary sites |
|
|
34 |
primary_site_counts <- table(gtex.phe$primary_site) |
|
|
35 |
|
|
|
36 |
return(primary_site_counts) |
|
|
37 |
} |
|
|
38 |
|
|
|
39 |
|