ixxmu / mp_duty

抓取网络文章到github issues保存
https://archives.duty-machine.now.sh/
116 stars 30 forks source link

GEO数据库读取官方RNA-seq count矩阵及预处理 #3702

Closed ixxmu closed 1 year ago

ixxmu commented 1 year ago

https://mp.weixin.qq.com/s/CIKsm-1L7vk1hGpa1lDBZw

ixxmu commented 1 year ago

GEO数据库读取官方RNA-seq count矩阵及预处理 by 生命数据科学

使用说明

  1. 库引入

  • 导入所需的R包:dplyrAnnotationDbiorg.Hs.eg.dbdata.table
  • 自定义GSE号输入

    • 当运行脚本时,它会提示您输入一个GSE号。
  • 数据下载

    • 根据您提供的GSE号,脚本会构造一个URL以从NCBI GEO下载相应的原始计数数据。
    • 下载的文件名是基于输入的GSE号。
  • 数据读取与处理

    • 使用data.table::fread函数读取下载的gzip压缩文件。
    • 将数据转换为矩阵,并将其行名设置为Entrez ID。
  • 标识转换

    • 利用mapIds函数将Entrez ID转换为Gene Symbols。
    • 删除存在NA的行。
  • 生成结果

    • 脚本最后会生成一个名为gene_counts的数据框,其中包含基因名称(Gene Symbols)及其对应的计数数据。

    代码

    library("dplyr")library("AnnotationDbi")library("org.Hs.eg.db")library("data.table")
    # 1. 自定义输入GSE号GSE_number <- "GSE60052"
    # 2. 分析得到对应的gene_countsurld <- "https://www.ncbi.nlm.nih.gov/geo/download/?format=file&type=rnaseq_counts"path <- paste(urld, paste("acc=", GSE_number, sep=""), paste("file=", GSE_number, "_raw_counts_GRCh38.p13_NCBI.tsv.gz", sep=""), sep="&")download.file(path, destfile = paste(GSE_number, "_raw_counts_GRCh38.p13_NCBI.tsv.gz", sep=""))
    raw_counts <- as.matrix(data.table::fread(paste(GSE_number, "_raw_counts_GRCh38.p13_NCBI.tsv.gz", sep=""), header=T, colClasses="integer"), rownames=1)rownames(raw_counts) <- mapIds(org.Hs.eg.db, keys = rownames(raw_counts), column = "SYMBOL", keytype = "ENTREZID", multiVals = "first")
    raw_counts <- raw_counts %>% .[!is.na(rownames(.)), ] %>% as.data.frame()
    gene_counts <- cbind(genes = rownames(raw_counts), raw_counts)
    ## 效果展示> gene_counts[1:5,1:5] genes GSM1464282 GSM1464283 GSM1464284 GSM1464285DDX11L1 DDX11L1 0 9 2 2WASH7P WASH7P 102 105 110 81MIR6859.1 MIR6859.1 2 1 8 1MIR1302.2HG MIR1302.2HG 0 4 0 5MIR1302.2 MIR1302.2 0 0 1 3


    ixxmu commented 1 year ago

    难道要把我的流程改成用counts? 虽然有的GEO确实没有上传counts

    Supremelu commented 9 months ago

    这个方法获得的counts与SRA数据获得counts有区别吗?大佬

    ixxmu commented 9 months ago

    这个方法获得的counts与SRA数据获得counts有区别吗?大佬

    不会有很大区别,除非他没有提供counts,一般直接用他geo提供的即可

    Supremelu commented 9 months ago

    非常感谢!!

    ---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2024年1月23日 22:02 | | 收件人 | @.> | | 抄送人 | @.> , @.> | | 主题 | Re: [ixxmu/mp_duty] GEO数据库读取官方RNA-seq count矩阵及预处理 (Issue #3702) |

    这个方法获得的counts与SRA数据获得counts有区别吗?大佬

    不会有很大区别,除非他没有提供counts,一般直接用他geo提供的即可

    — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>