forked from CCBR/DSP_Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_pkc_targets.qmd
56 lines (38 loc) · 1.05 KB
/
extract_pkc_targets.qmd
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
---
title: "Extract_PKC_Targets"
format: html
editor: visual
---
```{r}
# Load the jsonlite package
library(jsonlite)
library(tidyr)
library(dplyr)
```
```{r}
pkc.folder <- "/Users/cauleyes/CPTR/CPTR_nCounter_Protein_Thyroid/pkc/"
pkc.files <- list.files(pkc.folder)
target.list <- list()
for(file in pkc.files){
# Read the JSON file
file.path <- paste0(pkc.folder, file)
pkc.data <- fromJSON(file.path)
# Extract the "ProbeGroups" section
probe.groups <- pkc.data$ProbeGroups
# Save to the final list
target.list[[file]] <- probe.groups
}
# Flatten each data frame in the list
flattened.list <- lapply(names(target.list), function(name) {
# Add the list name as a new column for tracking
target.list[[name]] %>%
mutate(Source = name) %>%
unnest(Targets)
})
# Combine all the flattened data frames into a single data frame
final.df <- bind_rows(flattened.list)
# Export the targets list
write.csv(final.df,
"/Users/cauleyes/CPTR/CPTR_nCounter_Protein_Thyroid/pkc/target_list.csv",
row.names = FALSE)
```