Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tensorflow
GitHub Repository: tensorflow/docs-l10n
Path: blob/master/site/ja/io/tutorials/genome.ipynb
25118 views
Kernel: Python 3
#@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.

概要

このチュートリアルでは、一般的に使用されるゲノミクス IO 機能を提供するtfio.genomeパッケージについて解説します。これは、いくつかのゲノミクスファイル形式を読み取り、データを準備するための一般的な演算を提供します (例: One-Hot エンコーディングまたは Phred クオリティスコアを確率に解析します)。

このパッケージは、Google Nucleus ライブラリを使用して、主な機能の一部を提供します。

セットアップ

try: %tensorflow_version 2.x except Exception: pass !pip install tensorflow-io
import tensorflow_io as tfio import tensorflow as tf

FASTQ データ

FASTQ は、基本的な品質情報に加えて両方の配列情報を保存する一般的なゲノミクスファイル形式です。

まず、サンプルのfastqファイルをダウンロードします。

# Download some sample data: !curl -OL https://raw.githubusercontent.com/tensorflow/io/master/tests/test_genome/test.fastq

FASTQ データの読み込み

tfio.genome.read_fastqを使用してこのファイルを読みこみます (tf.data API は近日中にリリースされる予定です)。

fastq_data = tfio.genome.read_fastq(filename="test.fastq") print(fastq_data.sequences) print(fastq_data.raw_quality)

ご覧のとおり、返されたfastq_dataには fastq ファイル内のすべてのシーケンスの文字列テンソル (それぞれ異なるサイズにすることが可能) であるfastq_data.sequences、および、シーケンスで読み取られた各塩基の品質に関する Phred エンコードされた品質情報を含むfastq_data.raw_qualityが含まれています。

品質

関心がある場合は、ヘルパーオペレーションを使用して、この品質情報を確率に変換できます。

quality = tfio.genome.phred_sequences_to_probability(fastq_data.raw_quality) print(quality.shape) print(quality.row_lengths().numpy()) print(quality)

One-Hot エンコーディング

また、One-Hot エンコーダ―を使用してゲノムシーケンスデータ (A T C Gの塩基配列で構成される) をエンコードすることもできます。これに役立つ演算が組み込まれています。

one_hot = tfio.genome.sequences_to_onehot(fastq_data.sequences) print(one_hot) print(one_hot.shape)
print(tfio.genome.sequences_to_onehot.__doc__)