Skip to main content

A Python tool for converting SNP genotype data in PED format to a format suitable for STRUCTURE analysis

Project description

SNP2STR

A Python tool for converting SNP genotype data in PED file (.ped) format to a format suitable for STRUCTURE analysis.

Overview

SNP2STR processes genomic data files, specifically PED files (.ped) containing SNP (Single Nucleotide Polymorphism) genotype data, and converts them into a format that can be used for population structure analysis with STRUCTURE software. The tool handles the conversion of nucleotide bases to numeric codes required by STRUCTURE.

Features

  • Converts PED files (.ped) to STRUCTURE input format
  • Supports optional POPULATION file (.txt) and MAP file (.map)
  • Validates input data for consistency
  • Handles nucleotide base coding conversion
  • Provides command-line interface for easy usage
  • Supports header customization in output files

Installation

# Install from PyPI
pip install snp2str

# Or clone the repository
git clone https://github.com/vladgheorghe/snp2str.git
cd snp2str
pip install -e .

Requirements

  • Python 3.6+
  • pandas 2.2.3

Usage

Command Line Interface

# Basic usage with a PED file (.ped)
snp2str path/to/your/file.ped

# Using all optional files
snp2str path/to/your/file.ped path/to/your/populations.txt path/to/your/file.map

# Specify output path
snp2str path/to/your/file.ped --output custom_output.csv

# Skip header in output file
snp2str path/to/your/file.ped --skip-output-header

# Skip first line in input PED file (.ped)
snp2str path/to/your/file.ped --skip-input-header

Python API

from snp2str.process import process_files

# Basic usage
process_files(ped_path="path/to/your/file.ped")

# With all options
process_files(
    ped_path="path/to/your/file.ped",
    pop_path="path/to/your/populations.txt",
    map_path="path/to/your/file.map",
    add_header=True,
    output_path="custom_output.csv",
    skip_input_header=False
)

Input Files

  1. PED file (.ped) - Required

    • Contains genotype data with SNP information
    • Each row represents an individual
    • First 6 columns contain metadata, followed by genotype data
  2. POPULATION file (.txt) - Optional

    • Contains population information for each individual
    • One population identifier per line
  3. MAP file (.map) - Optional

    • Contains marker information
    • Used to generate headers in the output file

Output Format

The output is a CSV file formatted for STRUCTURE analysis:

  • Each individual is represented by two rows (one for each chromosome)
  • First column contains the individual identifier
  • Second column contains the population identifier (if provided)
  • Remaining columns contain the coded alleles

Base Coding

SNP bases are coded according to the following scheme:

  • A → 1
  • T → 2
  • G → 3
  • C → 4
  • Missing data → -9

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snp2str-0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snp2str-0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file snp2str-0.1.tar.gz.

File metadata

  • Download URL: snp2str-0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for snp2str-0.1.tar.gz
Algorithm Hash digest
SHA256 46f0dd3d89eaf31c64159b9921d1e98704dd2d2d98cbae2318d924398975363b
MD5 36eb8f11dcedc6c6cba48a068e968285
BLAKE2b-256 b0c4790fba01a20b7cfcf29006e793beee8bf4a79fc34064cccbb0fbcb82bd90

See more details on using hashes here.

File details

Details for the file snp2str-0.1-py3-none-any.whl.

File metadata

  • Download URL: snp2str-0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for snp2str-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 283c6735ff7d8991cf61cafed7e5952fe502d665132c1e43e38330d1c57596b4
MD5 051d9dd4f88bc6ca779ecf8957b08d05
BLAKE2b-256 5a3afd2f58ef9f39a59b20c1b62099068695a2f3a8091be997975b0833c4856b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page