在 R 中正确读取序列矩阵
Reading a series matrix properly in R
我下载 GSE60341_series_matrix.txt.gz 找到 here,当我将其读入 R table 时,
x <-read.table("GSE60341_series_matrix.txt", fill = TRUE)
我得到了行中的所有信息。换句话说,我得到一个大小矩阵
(42977 行和 3 列),而样本数应为 1951。
所以理想情况下,我应该得到 1951 行的 table 和(代表每个样本的一些 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"
类别(lane
、stimulation
、Sample_title
)中的信息连接成行,但我希望它们位于列中。我可以有一个 table,其中行代表样本,列代表 ,比如 [Sample_title, stimulation]
?
read.table
用于读取通用 ASCII table 格式,此文件采用 NCBI 基因表达综合 (GEO) 使用的特殊格式。
这是您需要做的:
通过将此代码粘贴到 R 来安装用于读取 GEO 文件的 GEOQuery 包:
source("http://bioconductor.org/biocLite.R")
biocLite("GEOquery")
使用此行将包加载到内存中:
library("GEOquery")
编辑以下行,将工作目录到文件的完整路径放在引号内,将数据作为对象读入内存gse
:
gse=getGEO(filename="~/Downloads/GSE60341_series_matrix.txt.gz")
现在,如果您 运行 View(gse)
您将在 gse 中看到一个格式良好的 table,其中包含 1950 行。
查看 GEOquery Documentation 了解更多信息。
我下载 GSE60341_series_matrix.txt.gz 找到 here,当我将其读入 R table 时,
x <-read.table("GSE60341_series_matrix.txt", fill = TRUE)
我得到了行中的所有信息。换句话说,我得到一个大小矩阵 (42977 行和 3 列),而样本数应为 1951。 所以理想情况下,我应该得到 1951 行的 table 和(代表每个样本的一些 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"
类别(lane
、stimulation
、Sample_title
)中的信息连接成行,但我希望它们位于列中。我可以有一个 table,其中行代表样本,列代表 ,比如 [Sample_title, stimulation]
?
read.table
用于读取通用 ASCII table 格式,此文件采用 NCBI 基因表达综合 (GEO) 使用的特殊格式。
这是您需要做的:
通过将此代码粘贴到 R 来安装用于读取 GEO 文件的 GEOQuery 包:
source("http://bioconductor.org/biocLite.R") biocLite("GEOquery")
使用此行将包加载到内存中:
library("GEOquery")
编辑以下行,将工作目录到文件的完整路径放在引号内,将数据作为对象读入内存
gse
:gse=getGEO(filename="~/Downloads/GSE60341_series_matrix.txt.gz")
现在,如果您 运行
View(gse)
您将在 gse 中看到一个格式良好的 table,其中包含 1950 行。查看 GEOquery Documentation 了解更多信息。