-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep4.SignalKataegis.Rmd
executable file
·68 lines (48 loc) · 1.41 KB
/
step4.SignalKataegis.Rmd
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
---
title: "teeth signal results"
author: "Keren Xu"
date: "09/12/2021"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = T)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(fig.width= 7, fig.height=5)
```
# Load packages
```{r}
library(tidyverse)
require(dplyr)
require(data.table)
library(pals)
library(colorblindr)
theme_set(theme_light())
list.dirs(path = "/DIR/signal.out", full.names = F, recursive = F) %>% dput()
```
## R Markdown
```{r}
mydir <- c() # a vector of paths to each individual samples
# read file path
all_paths <- paste0(mydir, "/kataegis_regions.csv")
# read file content
all_content <-
all_paths %>%
lapply(read.csv,
header = TRUE)
# read file name
all_filenames <- all_paths %>%
as.list()
# combine file content list and file name list
all_lists <- mapply(c, all_content, all_filenames, SIMPLIFY = FALSE)
# unlist all lists and change column name
all_result <- rbindlist(all_lists, fill = T)
# change column name
names(all_result)[4] <- "File.Path"
all_result$sample_id <- gsub("/kataegis_regions.csv", "", all_result$File.Path)
all_result$sample_id <- gsub("/dir/signal.out/","",all_result$sample_id)
all_result <- all_result %>% select(-File.Path)
all_result <- all_result %>% filter(!is.na(chr))
all_result %>% count(sample_id)
all_result %>% fwrite("signal_kataegis_regions.txt")
```