#########################设置我自己的r包加载路径,通常你不需要运行这段代码-----
.libPaths(c(
# '/home/rootyll/seurat_v5/',
"/usr/local/lib/R/site-library", "/usr/lib/R/site-library", "/usr/lib/R/library"
))
###################################################################################333
# 1.加载R包 ----
library(ggplot2)
library(cowplot)
library(paletteer)
library(gplots)
library(ggpubr)
library(ggsci)
library(stringr)
library(GO.db)
library(Seurat)
library(dplyr)
library(tibble)
library(readr)
#BiocManager::install('msigdb',site_repository = 'https://cran.rstudio.com/' )
library(msigdb)
# 加载必要的包
library(dplyr)
library(tidyr)
library(purrr)
library(GSVA)
library(parallel)
#1设置工作目录-----
dir.create("~/ipf_spatial_blem/human_ipf/2_addimages/",recursive = TRUE)
setwd('~/ipf_spatial_blem/human_ipf/2_addimages')
unique_pairs=read.csv("/home/rootyll/ipf_spatial_blem/human_ipf/2_addimages/unique_pairs.csv");unique_pairs
# c 获取文件夹名称列表-------
myfiles <- list.files("~/ipf_spatial_blem/human_ipf/hs_visium_spaceranger_output/",pattern = "V");myfiles
getwd()
file_data=unique_pairs
setwd("~/ipf_spatial_blem/human_ipf/hs_visium_spaceranger_output")
dir.create('/home/rootyll/ipf_spatial_blem/human_ipf/hs_images')
# 遍历文件数据
for(i in 1:nrow(file_data)) {
# 获取visium_files对应的文件夹路径
# i=1
folder <- file_data$visium_files[i] ;print(folder)
# 拼接tissue_hires_image.png的原路径
old_file_path <- file.path(folder, "spatial", "tissue_hires_image.png") ;print( old_file_path)
# 拼接新的文件名和路径
new_file_name <- paste0(file_data$image_names[i], "_tissue_hires_image.png")
new_file_path <- file.path('/home/rootyll/ipf_spatial_blem/human_ipf/hs_images', new_file_name) ;print(new_file_path)
# 如果文件存在,复制文件并重命名
if(file.exists(old_file_path)) {
file.copy(from = old_file_path, to = new_file_path)
} else {
warning(paste("File does not exist:", old_file_path))
}
}