if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("GEOquery")
install.packages(ggplot2)
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("GEOquery")
.libPaths(c("D:/Rpackages",.libPaths()))
install.packages(c("cluster"),"survival")
install.packages("survival")
.libPaths()
install.packages(limma)
install.packages("limma")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("limma")
BiocManager::install("limma",destdir="D:Rpackages")
library(limma)
library(ggplot2)
install.packages("ggplot2")
install.packages(pheatmap)
install.packages("ggplot2")
install.packages("pheatmap")
install.packages("org.Hs.eg.db")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("org.Hs.eg.db")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("org.Hs.eg.db")
install.packages(c("cluster","survival"))
install.packages("colorspace")
#???ð?
library("clusterProfiler")
#???ð?
library("clusterProfiler")
install.packages("stringi")
BiocManager::install("DOSE")
install.packages(c("cluster","survival"))
BiocManager::install("clusterProfiler")
BiocManager::install("enrichplot")
library("clusterProfiler")
library("org.Hs.eg.db")
library("enrichplot")
library("ggplot2")
library("gsva")
library("GSVA")
library("clusterProfiler")
library("clusterProfiler")
library("org.Hs.eg.db")
.libPaths("D:/Rpackages")
library("org.Hs.eg.db")
install.packages("TCGApolt")
install.packages("https://github.com/tjhwangxiong/tcgaplot/releases/download/v4.0.0/tcgaplot_4.0.0.zip")
group_list=c(rep('normal',3),rep('tumour_1',3),rep('tumour_2',3),rep('tumour_3',3))
print(group_list)
group_list1 <-factor(group_list)
design=model.matrix(~group_list)
group_list1
colnames(design) <- levels(group_list1)
rownames(design) <- paste0("sample",1:12)
View(design)
group_list3 <-factor(group_list)
design3 <- model.matrix(~0+group_list3)
View(design3)
colnames(design3) <- levels(group_list3)
rownames(design3) <- paste0("sample",1:12)
#1.载入包
library(tableone)
library(survival)
##画森林图的包
library(forestplot)
library(stringr)
library(broom)
#2.清理工作环境
rm(list = ls())
#3.读入数据
aa<- read.csv('20210209.csv')
library(dplyr)
library(ggplot2)
library(drc)
# 示例数据（替换为实际数据）
data <- data.frame(
group = c(rep("shNC", 6), rep("shFABP5", 6)),
concentration = c(0.1, 1, 5, 10, 20, 50, 0.1, 1, 5, 10, 20, 50),
inhibition = c(5.2, 28.7, 52.3, 78.1, 89.4, 94.5, 15.6, 45.2, 75.8, 92.3, 96.7, 98.1)
)
# 转换抑制率为比例
data$inhibition <- data$inhibition / 100
# 检查数据中是否存在缺失值
if (any(is.na(data))) {
data <- na.omit(data)
}
# 尝试使用 LL.3() 模型进行拟合
fit <- drm(inhibition ~ log10(concentration) * group, data = data, fct = LL.3())
library(dplyr)
library(ggplot2)
library(drc)
# 示例数据（替换为实际数据）
data <- data.frame(
group = c(rep("shNC", 6), rep("shFABP5", 6)),
concentration = c(0.1, 1, 5, 10, 20, 50, 0.1, 1, 5, 10, 20, 50),
inhibition = c(5.2, 28.7, 52.3, 78.1, 89.4, 94.5, 15.6, 45.2, 75.8, 92.3, 96.7, 98.1)
)
# 转换抑制率为比例
data$inhibition <- data$inhibition / 100
# 检查数据中是否存在缺失值、无穷值或非数值
has_na <- any(is.na(data))
has_inf <- any(is.infinite(data))
library(dplyr)
library(ggplot2)
library(drc)
# 示例数据（替换为实际数据）
data <- data.frame(
group = c(rep("shNC", 6), rep("shFABP5", 6)),
concentration = c(0.1, 1, 5, 10, 20, 50, 0.1, 1, 5, 10, 20, 50),
inhibition = c(5.2, 28.7, 52.3, 78.1, 89.4, 94.5, 15.6, 45.2, 75.8, 92.3, 96.7, 98.1)
)
# 转换抑制率为比例
data$inhibition <- data$inhibition / 100
# 检查每一列是否存在缺失值、无穷值或非数值
has_na <- any(sapply(data, function(x) any(is.na(x))))
has_inf <- any(sapply(data, function(x) any(is.infinite(x))))
has_nan <- any(sapply(data, function(x) any(is.nan(x))))
# 输出检查结果
cat("数据中是否存在缺失值:", has_na, "\n")
cat("数据中是否存在无穷值:", has_inf, "\n")
cat("数据中是否存在非数值:", has_nan, "\n")
# 若存在缺失值，删除含缺失值的行
if (has_na) {
data <- na.omit(data)
}
# 尝试使用 LL.3() 模型进行拟合
fit <- drm(inhibition ~ log10(concentration) * group, data = data, fct = LL.3())
# 设置工作环境
rm(list = ls())
setwd("D:/马明福/新文章/原始图/IHCscore")
# 加载必要的包
library(ggplot2)
library(ggsignif)
library(reshape2) # 因为使用了melt函数
# 加载数据
df <- read.table("IHCscoreHIF1A.txt", header = T, check.names = F)
# 转换数据
data <- melt(df)
data$G <- rep(c("N", "T"), each = 15)
# 自定义函数来格式化 p 值
format_p_value <- function(p) {
if (p < 0.001) {
return("p < 0.001")
} else {
return(paste0("p = ", round(p, 3)))
}
}
# 进行 t 检验并获取 p 值
t_test_result <- t.test(value ~ G, data = data)
p_value <- t_test_result$p.value
# 基础绘图
p1 <- ggplot(data, aes(G, value)) +
# 绘制条形图，设置宽度参数
geom_bar(aes(fill = G), color = 'grey50', stat = "summary",
fun = mean, position = "dodge", size = 0.8, width = 0.6) +
# 误差棒
stat_summary(fun.data ='mean_sd', geom = "errorbar", width = 0.2, size = 0.8) +
# 设置 x 轴和 y 轴标签
labs(x = NULL, y = "IHC score of HIF1α") +
# 颜色
scale_fill_manual(values = c("#ADD8E6", "#F4A460")) +
# 显著性，显示具体 p 值
geom_signif(comparisons = list(c("N", "T")),
map_signif_level = format_p_value,
test = "t.test",
# 增大星号大小
textsize = 12,face = "bold",
y_position = 8.5,
# 设置tip_length为0，去除两端的竖线
tip_length = 0.03,
# 设置lineheight为0，去除中间的横线
lineheight = 1,
vjust = -0.5,
# 加深星号颜色
size = 0.8, color = "black", alpha = 1) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 10.5), breaks = c(0, 2, 4, 6, 8, 10)) +
# 修改 x 轴刻度标签
scale_x_discrete(labels = c("N" = "Normal", "T" = "Cancer")) +
# 主题相关设置
theme_classic() +
theme(axis.text = element_text(size = 28,face = "bold"),
legend.position = "none",
axis.line = element_line(size = 0.8),
# 增大 y 轴标签字体大小
axis.title.y = element_text(size = 30,face = "bold"))
# 显示图形
print(p1)
# 设置工作环境
rm(list = ls())
setwd("D:/马明福/新文章/原始图/IHCscore")
# 加载必要的包
library(ggplot2)
library(ggsignif)
library(reshape2) # 因为使用了melt函数
# 自定义 mean_sd 函数
mean_sd <- function(x) {
m <- mean(x)
s <- sd(x)
data.frame(y = m, ymin = m - s, ymax = m + s)
}
# 加载数据
df <- read.table("IHCscoreHIF1A.txt", header = T, check.names = F)
# 转换数据
data <- melt(df)
data$G <- rep(c("N", "T"), each = 15)
# 自定义函数来格式化 p 值
format_p_value <- function(p) {
if (p < 0.001) {
return("p < 0.001")
} else {
return(paste0("p = ", round(p, 3)))
}
}
# 进行 t 检验并获取 p 值
t_test_result <- t.test(value ~ G, data = data)
p_value <- t_test_result$p.value
# 基础绘图
p1 <- ggplot(data, aes(G, value)) +
# 绘制条形图，设置宽度参数
geom_bar(aes(fill = G), color = 'grey50', stat = "summary",
fun = mean, position = "dodge", size = 0.8, width = 0.6) +
# 误差棒
stat_summary(fun.data = mean_sd, geom = "errorbar", width = 0.2, size = 0.8) +
# 设置 x 轴和 y 轴标签
labs(x = NULL, y = "IHC score of HIF1α") +
# 颜色
scale_fill_manual(values = c("#ADD8E6", "#F4A460")) +
# 显著性，显示具体 p 值
geom_signif(comparisons = list(c("N", "T")),
map_signif_level = format_p_value,
test = "t.test",
# 增大星号大小
textsize = 12,face = "bold",
y_position = 8.5,
# 设置tip_length为0，去除两端的竖线
tip_length = 0.03,
# 设置lineheight为0，去除中间的横线
lineheight = 1,
vjust = -0.5,
# 加深星号颜色
size = 0.8, color = "black", alpha = 1) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 10.5), breaks = c(0, 2, 4, 6, 8, 10)) +
# 修改 x 轴刻度标签
scale_x_discrete(labels = c("N" = "Normal", "T" = "Cancer")) +
# 主题相关设置
theme_classic() +
theme(axis.text = element_text(size = 28,face = "bold"),
legend.position = "none",
axis.line = element_line(size = 0.8),
# 增大 y 轴标签字体大小
axis.title.y = element_text(size = 30,face = "bold"))
# 显示图形
print(p1)
# 保存图形
ggsave("IHCHIF1A.png", plot = p1, width = 5, height = 6, dpi = 300)
rm(list = ls())
setwd("D:/马明福/新文章/原始图/IHCscore")
# 加载必要的包
library(ggplot2)
library(ggsignif)
library(reshape2) # 因为使用了melt函数
# 自定义 mean_sd 函数
mean_sd <- function(x) {
m <- mean(x)
s <- sd(x)
data.frame(y = m, ymin = m - s, ymax = m + s)
}
# 加载数据
df <- read.table("IHCscorep110α.txt", header = T, check.names = F)
# 转换数据
data <- melt(df)
data$G <- rep(c("N", "T"), each = 15)
# 自定义函数来格式化 p 值
format_p_value <- function(p) {
if (p < 0.001) {
return("p < 0.001")
} else {
return(paste0("p = ", round(p, 3)))
}
}
# 进行 t 检验并获取 p 值
t_test_result <- t.test(value ~ G, data = data)
p_value <- t_test_result$p.value
# 基础绘图
p1 <- ggplot(data, aes(G, value)) +
# 绘制条形图，设置宽度参数
geom_bar(aes(fill = G), color = 'grey50', stat = "summary",
fun = mean, position = "dodge", size = 0.8, width = 0.6) +
# 误差棒
stat_summary(fun.data = mean_sd, geom = "errorbar", width = 0.2, size = 0.8) +
# 设置 x 轴和 y 轴标签
labs(x = NULL, y = "IHC score of p110α") +
# 颜色
scale_fill_manual(values = c("#ADD8E6", "#F4A460")) +
# 显著性，显示具体 p 值
geom_signif(comparisons = list(c("N", "T")),
map_signif_level = format_p_value,
test = "t.test",
# 增大星号大小
textsize = 12,face = "bold",
y_position = 8.5,
# 设置tip_length为0，去除两端的竖线
tip_length = 0.03,
# 设置lineheight为0，去除中间的横线
lineheight = 1,
vjust = -0.5,
# 加深星号颜色
size = 0.8, color = "black", alpha = 1) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 10.5), breaks = c(0, 2, 4, 6, 8, 10)) +
# 修改 x 轴刻度标签
scale_x_discrete(labels = c("N" = "Normal", "T" = "Cancer")) +
# 主题相关设置
theme_classic() +
theme(axis.text = element_text(size = 28,face = "bold"),
legend.position = "none",
axis.line = element_line(size = 0.8),
# 增大 y 轴标签字体大小
axis.title.y = element_text(size = 30,face = "bold"))
# 显示图形
print(p1)
# 保存图形
ggsave("IHCHIF1A.png", plot = p1, width = 5, height = 6, dpi = 300)
# 保存图形
ggsave("IHCP110a.png", plot = p1, width = 5, height = 6, dpi = 300)
# 设置工作环境
rm(list = ls())
setwd("D:/马明福/新文章/原始图/IHCscore")
# 加载必要的包
library(ggplot2)
library(ggsignif)
library(reshape2) # 因为使用了melt函数
# 自定义 mean_sd 函数
mean_sd <- function(x) {
m <- mean(x)
s <- sd(x)
data.frame(y = m, ymin = m - s, ymax = m + s)
}
# 加载数据
df <- read.table("IHCscoreHIF1A.txt", header = T, check.names = F)
# 转换数据
data <- melt(df)
data$G <- rep(c("N", "T"), each = 15)
# 自定义函数来格式化 p 值
format_p_value <- function(p) {
if (p < 0.001) {
return("p < 0.001")
} else {
return(paste0("p = ", round(p, 3)))
}
}
# 进行 t 检验并获取 p 值
t_test_result <- t.test(value ~ G, data = data)
p_value <- t_test_result$p.value
# 基础绘图
p1 <- ggplot(data, aes(G, value)) +
# 绘制条形图，设置宽度参数
geom_bar(aes(fill = G), color = 'grey50', stat = "summary",
fun = mean, position = "dodge", size = 0.8, width = 0.6) +
# 误差棒
stat_summary(fun.data = mean_sd, geom = "errorbar", width = 0.2, size = 0.8) +
# 设置 x 轴和 y 轴标签
labs(x = NULL, y = "IHC score of HIF1α") +
# 颜色
scale_fill_manual(values = c("#ADD8E6", "#F4A460")) +
# 显著性，显示具体 p 值
geom_signif(comparisons = list(c("N", "T")),
map_signif_level = format_p_value,
test = "t.test",
# 增大星号大小
textsize = 12,face = "bold",
y_position = 8.5,
# 设置tip_length为0，去除两端的竖线
tip_length = 0.03,
# 设置lineheight为0，去除中间的横线
lineheight = 1,
vjust = -0.5,
# 加深星号颜色
size = 0.8, color = "black", alpha = 1) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 10.5), breaks = c(0, 2, 4, 6, 8, 10)) +
# 修改 x 轴刻度标签
scale_x_discrete(labels = c("N" = "Normal", "T" = "Cancer")) +
# 主题相关设置
theme_classic() +
theme(axis.text = element_text(size = 28,face = "bold"),
legend.position = "none",
axis.line = element_line(size = 0.8),
# 增大 y 轴标签字体大小
axis.title.y = element_text(size = 30,face = "bold"))
# 显示图形
print(p1)
# 保存图形
ggsave("IHCHIF1A.png", plot = p1, width = 5, height = 6, dpi = 300)
