• Log In
 Visit the Pennsylvania State University Home Page

Yuka Imamura Kawasawa

yimamura@pennstatehealth.psu.edu

  • Projects
    • Neurogenomics
    • Point-of-care exosomal biomarkers
    • Osteosarcoma
    • EIBDG (Education Initiative in Big Data Genomics)
  • Blog
  • Publications
  • Conference Abstracts
  • Contact info
  • Yuka’s availability
  • useful resources
    • College of Medicine Events Calendar
    • IPA (ingenuity pathway analysis)
    • HPC (high performance computation) cluster
    • Remote Access VPN
    • IT requests; software installation and troubleshooting etc..
    • Link to software downloads
    • Secure File Transfer through file drop
    • Useful resources from Hershey library
    • How to send in cells for RNA-sequencing
    • How to send in tissues for RNA extraction
    • Sample shipment from UP (University Park, aka Main Campus of PSU)
    • primer (oligo) synthesis (internal)
    • poster printing service (internal)
    • eagle-i
    • classroom and event scheduling
    • Ship out form
    • iLab training
    • VoiceThread
  • NAT_2nd
  • NAT_3rd
  • NAT2020

Splitting .bam file by a chromosome in a loop

Some bioinformatic tips I shared with my client:

The task is splitting .bam files by each chromosome (1-22, X, and Y for humans). I referred this site:

https://www.biostars.org/p/9130/

but what if you have many .bam files you have in a directory? We had ~40 .bams to start with so you would definitely want to run the job in one loop command instead of running the above 40 times manually.

This is what it worked:

#split bams

for file in *_chr.bam; do filename=`echo $file | cut -d “.” -f 1`; for chrom in `seq 1 22` X Y; do samtools view -bh $file chr${chrom} > ${filename}_${chrom}.bam; done; done

#make index file
for file in *_chr_*.bam; do samtools index $file; done

The result is 24 .bam files + 24 .bai files X ~40 samples = about 1,500 files were created overnight! 🙂

-Yuka

Leave a Reply

You must be logged in to post a comment.

Follow Us!

Follow Us on TwitterFollow Us on LinkedIn

Calendar

January 2017
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Oct   Feb »

Recent Posts

  • BioAnalyzer DNA/RNA options explained March 23, 2022
  • how to access to our new results folder February 13, 2022
  • Illumina NGS read number and length January 16, 2022
  • We are hiring! (3/3) December 15, 2021
  • We are hiring! 2/3 November 2, 2021
  • We are hiring! 1/3 October 7, 2021
  • Moldovan lab is recognized! April 13, 2021
  • NGS analysis of IGF2BP1’s role in neuroblastoma April 7, 2021
  • We are looking for a talented Research Tech! February 25, 2021
  • How to request 10X Genomics’ scRNA-seq October 13, 2020
  • Extracellular Vesicles getting hot in Hershey! September 17, 2020
  • A new paper came out in Neuron! July 29, 2020
  • 10XGenomics single cell genomics is here! June 11, 2020
  • Ming’s first author paper is out in collaboration with Dr. Kenny Futai! June 11, 2020
  • 2 papers in Blood are out! June 11, 2020
  • My first paper around bone cancer! April 19, 2020
  • A Science Immunology paper is out! April 19, 2020
  • Social distancing practices at our lab, in light of c19 epidemic March 19, 2020
  • Nature Neuroscience paper is out! March 18, 2020
  • A new paper came out from Evan@Gallo group! February 19, 2020

access counts

 Visit the Pennsylvania State University Home Page
Copyright 2025 © The Pennsylvania State University Privacy Non-Discrimination Equal Opportunity Accessibility Legal