在R中正确读取一个系列矩阵

Cur*_*ous 4 r text-files

我在这里找到 GSE60341_series_matrix.txt.gz ,当我把它读到R表中时,

x <-read.table("GSE60341_series_matrix.txt", fill = TRUE)
Run Code Online (Sandbox Code Playgroud)

我得到了行中的所有信息.换句话说,我得到一个大小的矩阵(42977行和3列),而样本的数量应该是1951.所以理想情况下,我应该得到一个1951行的表和(一些k列代表每个样本).

打开文本文件让我,

    sapiens"    "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"  "Homo sapiens"
!Sample_title   "20120811_NC18_NC18_01" "20120811_NC18_NC18_02" "20120811_NC18_NC18_03" "20120811_NC18_NC18_04" "20120811_NC18_NC18_05"
    !Sample_characteristics_ch1 "stimulation: Unstim"   "stimulation: Activated"    "stimulation: IFNb" "stimulation: Unstim"   "stimulation: Activated"    "stimulation: IFNb" "stimulation: Unstim"   "stimulation: Activated"    "stimulation: IFNb" "stimulation: Unstim"   "stimulation: Activated"    "stimulation: IFNb" "stimulation: Unstim"   "stimulation: Activated"    "stimulation: IFNb" "stimulation: Unstim"   "stimulation: Activated"    "stimulation: IFNb" "stimulation: Unstim"   "stimulation: Activated"

"lane: 9"   "lane: 11"  "lane: 12"  "lane: 1"   "lane: 2"   "lane: 3"   "lane: 4"   "lane: 5"   "lane: 6"   "lane: 7"   "lane: 8"   "lane: 9"   "lane: 10"  "lane: 11"  "lane: 12"  "lane: 1"   "lane: 2"   "lane: 3"
Run Code Online (Sandbox Code Playgroud)

在类别中的信息(lane,stimulation,Sample_title)串接为行,但我希望他们能在列.我可以有一个表格,其中行代表样本,列代表[Sample_title, stimulation]吗?

Mic*_*ori 8

read.table 用于读取通用ASCII表格式,该文件采用NCBI Gene Expression Omnibus(GEO)使用的特殊格式.

这是你需要做的:

  1. 通过将此代码粘贴到R中来安装GEOQuery包以读取GEO文件:

    source("http://bioconductor.org/biocLite.R")
    biocLite("GEOquery")
    
    Run Code Online (Sandbox Code Playgroud)
  2. 使用以下行将包加载到内存中:

    library("GEOquery")
    
    Run Code Online (Sandbox Code Playgroud)
  3. 编辑以下行,将工作目录中的完整路径放到引号内的文件中,以将数据作为对象读入内存gse:

    gse=getGEO(filename="~/Downloads/GSE60341_series_matrix.txt.gz")
    
    Run Code Online (Sandbox Code Playgroud)
  4. 现在,如果你运行,View(gse)你会看到一个格式很好的表,在gse中有1950行.

    查看GEOquery文档以获取更多信息.

  • 答案很好,但如果您在 getGEO 中选择文件名选项,则可能需要使用 getGPL = FALSE 选项。否则该函数将尝试下载相应的 GPL 文件,这可能会失败(根据我的经验)。 (2认同)