-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata_formatting.R
68 lines (52 loc) · 1.51 KB
/
metadata_formatting.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Metadata processing
library(dplyr)
library(data.table)
# TCGA ----------------------------------------------------------------------------
tcga_meta <- fread("http://snaptron.cs.jhu.edu/data/tcgav2/samples.tsv")
tcga_meta <- tcga_meta %>%
mutate(sample = gsub("[A-Z]$", "", gdc_cases.samples.submitter_id)) %>%
select(
sample,
gdc_cases.project.name,
gdc_cases.samples.sample_type,
gdc_cases.project.primary_site
) %>%
rename(
description = gdc_cases.project.name,
tissue = gdc_cases.project.primary_site,
type = gdc_cases.samples.sample_type
) %>%
mutate(
set = "TCGA",
simple_type = "Tumor"
)
# GTEx ----------------------------------------------------------------------------
gtex_meta <- fread("http://snaptron.cs.jhu.edu/data/gtexv2/samples.tsv")
gtex_meta <- gtex_meta %>%
select(SAMPID, SMTS, SMTSD) %>%
rename(
sample = SAMPID,
tissue = SMTS,
description = SMTSD
) %>%
mutate(
set = "GTEX",
simple_type = "Normal",
type = "Normal"
)
gtex_meta[!grepl("GTEX", gtex_meta$sample)]$simple_type <- "Tumor"
gtex_meta[!grepl("GTEX", gtex_meta$sample)]$type <- "Tumor"
gtex_meta <- gtex_meta %>%
filter(sample != "") # Drop empty samples
# Merge metadata and save ------------------------------------------------------------
meta_snaptron <- rbind(tcga_meta, gtex_meta)
meta_snaptron %>%
select(
sample,
type,
tissue,
description,
set,
simple_type
)
#fwrite(meta_snaptron, "output/20210205_metadata_tcga_gtex.tab")