Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tensorflow
GitHub Repository: tensorflow/docs-l10n
Path: blob/master/site/ko/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 패키지를 시연합니다. 즉, 여러 게놈 파일 형식을 읽고 데이터를 준비하기 위한 몇 가지 일반적인 연산도 제공합니다(예: 원-핫 인코딩 또는 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에는 시퀀스에서 읽은 각 기본 정보의 품질에 관한 Phred 인코딩 품질 정보를 포함하는 fastq_data.raw_quality와 함께 fastq 파일(각각 크기가 다를 수 있음)에 있는 모든 시퀀스의 문자열 텐서인 fastq_data.sequences가 있습니다.

품질

관심이 있는 경우 도우미 op를 사용하여 이 품질 정보를 확률로 변환할 수 있습니다.

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

원-핫 인코딩

또한, 원-핫 인코더를 사용하여 A T C G 염기 서열로 구성된 게놈 시퀀스 데이터를 인코딩할 수도 있습니다. 인코딩에 도움이 되는 내장 연산이 있습니다.

print(tfio.genome.sequences_to_onehot.__doc__)
print(tfio.genome.sequences_to_onehot.__doc__)