Skip to content

Commit

Permalink
update Get_CorrectBg_p
Browse files Browse the repository at this point in the history
  • Loading branch information
dengchunyu committed Sep 3, 2023
1 parent eaebab8 commit 38a95a2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
48 changes: 24 additions & 24 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
scale_colour_gradient2(low="#3A71AA",mid="white",high="#B22028",midpoint=0)+
theme_bw()+
theme (axis.text.x = element_text (angle = 45, hjust = 1))+theme(legend.position = "top")
pdf("D:\\OneDrive\\类器官空间\\DEanalysis\\celltypemarker_chenming8.4check_dotplot.pdf",width = 14,height = 4)
DotPlot(scdata,features=unique(GENES),group.by="New_celltype",assay="SCT")+
scale_colour_gradient2(low="#3A71AA",mid="white",high="#B22028",midpoint=0)+
theme_bw()+
theme (axis.text.x = element_text (angle = 45, hjust = 1))+theme(legend.position = "top")
dev.off()
library(Seurat)
library(dplyr)
library(ggplot2)
library(patchwork)
library(ggpubr)
scdata<-readRDS("D:\\OneDrive\\类器官空间\\DEanalysis\\H9_D60_2_stdata.rds")
scdata<-subset(scdata,subset = seurat_clusters!=6 & seurat_clusters!=7)
scdata$seurat_clusters<-as.character(scdata$seurat_clusters)
scdata$seurat_clusters[scdata$seurat_clusters==0]<-6
scdata$New_celltype<-scdata$seurat_clusters
table(scdata$New_celltype)
scdata$New_celltype[scdata$New_celltype=="6"]<-"RPC/PC"
scdata$New_celltype[scdata$New_celltype=="1"]<-"RGC/RPC"
scdata$New_celltype[scdata$New_celltype=="2"]<-"RPC/PC_precursors/MC"
scdata$New_celltype[scdata$New_celltype=="3"]<-"RPE/RPE_progenitors"
scdata$New_celltype[scdata$New_celltype=="4"]<-"hRSLCs"
scdata$New_celltype[scdata$New_celltype=="5"]<-"RPC/PC/AC_HC/BC/MC"
saveRDS(scdata,"D:\\OneDrive\\类器官空间\\DEanalysis\\H9_D60_2_final_stdata.rds")
Expand Down Expand Up @@ -510,3 +486,27 @@ celltype=T# Whether to run the celltype process.
##------ Wed Aug 23 16:06:04 2023 ------##
##------ Wed Aug 23 16:06:05 2023 ------##
##------ Wed Aug 23 16:06:07 2023 ------##
devtools::load_all(".")
Pagwas_data<-scPagwas_main(Pagwas = NULL,
gwas_data =system.file("extdata", "GWAS_summ_example.txt", package = "scPagwas"), # The GWAS Summary statistics files
Single_data =system.file("extdata", "scRNAexample.rds", package = "scPagwas"),# scRNA-seq data in seruat format with "RNA" assays and normalized.
output.prefix="test", # the prefix name for output files
output.dirs="scPagwastest_output",# the directory file's name for output
block_annotation = block_annotation,# gene position in chromosome is provided by package.
assay="RNA", # the assays for scRNA-seq data to use.
Pathway_list=Genes_by_pathway_kegg,# pathway list is provided by package, including gene symbols.
n.cores=1,
iters_singlecell = 10,
chrom_ld = chrom_ld,# The LD data is provided by package.
singlecell=T, # Whether to run the singlecell process.
celltype=T# Whether to run the celltype process.
)
##------ Mon Aug 28 10:13:27 2023 ------##
##------ Mon Aug 28 10:13:32 2023 ------##
##------ Mon Aug 28 10:14:06 2023 ------##
##------ Mon Aug 28 10:14:06 2023 ------##
##------ Mon Aug 28 10:14:06 2023 ------##
##------ Mon Aug 28 10:14:08 2023 ------##
##------ Mon Aug 28 10:14:17 2023 ------##
##------ Mon Aug 28 10:14:18 2023 ------##
##------ Mon Aug 28 10:14:20 2023 ------##
6 changes: 3 additions & 3 deletions R/Get_CorrectBg_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#' @param scPagwas_topgenes gene list
#' @return correct_pdf
#' @export
Get_CorrectBg_p<-function(Single_data,scPagwas.TRS.Score, iters_singlecell,n_topgenes,scPagwas_topgenes){
gene_matrix <- GetAssayData(Single_data, slot = "data", assay = 'RNA')
Get_CorrectBg_p<-function(Single_data,scPagwas.TRS.Score, iters_singlecell,n_topgenes,scPagwas_topgenes,assay){
gene_matrix <- GetAssayData(Single_data, slot = "data", assay = assay)
mat_ctrl_raw_score <- matrix(0, nrow =ncol(gene_matrix), ncol = iters_singlecell)
dic_ctrl_list <- list()
pb <- txtProgressBar(style = 3)
Expand All @@ -17,7 +17,7 @@ Get_CorrectBg_p<-function(Single_data,scPagwas.TRS.Score, iters_singlecell,n_top
set.seed(i)
dic_ctrl_list[[i]] <- sample(rownames(Single_data), n_topgenes)
Single_data<-Seurat::AddModuleScore(Single_data,
assay = 'RNA',
assay = assay,
list(dic_ctrl_list[[i]]),
name = c("contr_genes")
)
Expand Down
3 changes: 2 additions & 1 deletion R/scPagwas_main.R
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ scPagwas_main <- function(Pagwas = NULL,
scPagwas.TRS.Score=Single_data$scPagwas.TRS.Score1,
iters_singlecell=iters_singlecell,
n_topgenes=n_topgenes,
scPagwas_topgenes=scPagwas_topgenes
scPagwas_topgenes=scPagwas_topgenes,
assay=assay
)
Pagwas$Random_Correct_BG_pdf <- correct_pdf
message("* Get Merged pvalue for each celltype!")
Expand Down
3 changes: 2 additions & 1 deletion man/Get_CorrectBg_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38a95a2

Please sign in to comment.