-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathN02_GeoMx_Decon.R
74 lines (56 loc) · 1.66 KB
/
N02_GeoMx_Decon.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
69
70
71
72
73
74
#### Analysis GeoMx DSP data: deconvolution####
## author: Antonietta Salerno
## date: 17/06/2024
BiocManager::install("NanoStringNCTools")
BiocManager::install("GeomxTools")
BiocManager::install("GeoMxWorkflows")
library(NanoStringNCTools)
library(GeomxTools)
library(GeoMxWorkflows)
library(knitr)
library(dplyr)
library(ggforce)
library(ggplot2)
library(ggcharts)
library(MAST)
library(openxlsx)
library(patchwork)
library(clusterProfiler)
library("tibble")
library("Seurat")
library("fgsea")
library("stringr")
### 1 - Load data ####
setwd("~/Library/CloudStorage/OneDrive-UNSW/TEPA_project")
source("TEPA_code/supportFunctions.R")
#### 8 - Deconvolution analysis using SingleR ####
BiocManager::install("SpatialDecon")
library(SpatialDecon)
# Run SpatialDecon
results <- decon(
dataset = dataset,
segmentAnnotations = SampleAnnotationFile,
cell_profile = aggregated_expression_matrix
)
# View the results
head(results)
#source("TEPA_code/DWLS-master/Deconvolution_functions.R")
# library(usethis)
# usethis::edit_r_environ()
dataSC <- LoadSeuratRds("TEPA_results/S08_seusetFull.SeuratRds")
Idents(dataSC) <- "scType"
# merge with tumor
dataBulk <- LoadSeuratRds("TEPA_results/N00_seusetNanoRed.Rds", assay = "GeoMx")
labels = unique(Idents(dataSC))
scdata <- GetAssayData(dataSC[["integrated"]], slot = "scale.data")
spdata <- GetAssayData(seuset_nano, slot = "scale.data")
library(devtools)
library("SingleR")
pred <- SingleR(test=dataSC, ref=dataBulk, labels=labels, de.method="wilcox")
table(pred$labels)
### Spatial Deconvolution with MuSiC
install.packages('devtools')
# install the MuSiC package
devtools::install_github('xuranw/MuSiC')
# load
library(MuSiC)