Wednesday, January 28, 2015

GATK to detect strand bias


-A StrandBiasBySample: It directly outputs counts of read depth per allele (both ref and alt) for each strand orientation. 
Strand bias is a type of sequencing bias in which one DNA strand is favored over the other, which can result in incorrect evaluation of the amount of evidence observed for one allele vs. the other. The StrandBiasBySample annotation is produces read counts per allele and per strand that are used by other annotation modules (FisherStrand and StrandOddsRatio) to estimate strand bias using statistical approaches.
This annotation produces 4 values, corresponding to the number of reads that support the following (in that order):
  • the reference allele on the forward strand
  • the reference allele on the reverse strand
  • the alternate allele on the forward strand
  • the alternate allele on the reverse strand

Example

GT:AD:GQ:PL:SB  0/1:53,51:99:1758,0,1835:23,30,33,18
 
In this example, the reference allele is supported by 23 forward reads and 30 reverse reads, the alternate allele is supported by 33 forward reads and 18 reverse reads.

Command line example

java \
    -Xmx${MEM}                                                         \
    -Djava.io.tmpdir=${JAVA_TMPDIR}                                    \
    -jar ${GATK}                                                       \
    -T GenotypeGVCFs                                                   \
    -R ${REF_SEQ}                                                      \
    -A Coverage                                                        \
    -A FisherStrand                                                    \
    -A StrandBiasBySample                                              \
    -D $SNP_DBSNP                                                      \
    -o ${SMPL_NAME}.vcf                                                \
    -nt $PROCS                                                         \
    -V samples.vcf.list
 
 
 
Annotation about VCF INFO column:
MLEAC: maximum likelihood expectation of allele count
MLEAF: maximum likelihood expectation of allele frequency
##FORMAT=<ID=MLEAC,Number=A,Type=Integer,Description="Maximum likelihood expectation (MLE) for the allele counts (not necessarily the same as the AC), for each ALT allele, in the same order as listed, for this pool">                                                                
##FORMAT=<ID=MLEAF,Number=A,Type=Float,Description="Maximum likelihood expectation (MLE) for the allele frequency (not necessarily the same as the AF), for each ALT allele, in the same order as listed, for this pool">   

Friday, January 16, 2015

CentOS 7 Minimal kickstart file

I searched around a bit and couldn’t find any published kickstart files around for CentOS 7 (and the ones I did, didn’t work correctly and looked overly complex), therefore I’m attaching my CentOS 7 minimal kickstart file for anyone else who may be searching for one!
Notes:
1) Firewall service and selinux are disabled in this kickstart file (for testing). Please change them to enabled if preferred.
2) Filesystem is XFS with LVM
3) Update url and repo with your local mirror if preferred.
4) Below is the content of the kickstart file.

install
lang en_GB.UTF-8
keyboard us
timezone Australia/Melbourne
auth --useshadow --enablemd5
selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
ignoredisk --only-use=sda
reboot

bootloader --location=mbr
zerombr
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=200
part pv.01 --size=1 --grow
volgroup rootvg01 pv.01
logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow

rootpw --iscrypted $YOUR_ROOT_PASSWORD_HASH_HERE

repo --name=base --baseurl=http://mirror.cogentco.com/pub/linux/centos/7/os/x86_64/
url --url="http://mirror.cogentco.com/pub/linux/centos/7/os/x86_64/"

%packages --nobase --ignoremissing
@core
%end

Please let me know if you have any issues or have suggestions to improve the above CentOS 7 minimal kickstart file.

Thursday, January 15, 2015

CCIE Data Center: FiberChannel 101

This is a 2-hour introductory course on Fibre Channel protocol. Nicely explained:

https://www.youtube.com/watch?v=vE1mkTxOajc

by iPexpert

KVM and CentOS-6

CentOS 6 has native availability of KVM virtualization support and tools in the base distribution. Dell provides two whitepapers about how to use KVM in CentOS 6, part 1 and part 2.
See the meta packages contained in:
# yum grouplist | grep -i virt 

1. Host Setup


Install all the packages you might need.
yum -y install @virt* dejavu-lgc-* xorg-x11-xauth tigervnc \
libguestfs-tools policycoreutils-python bridge-utils 

If you have use any directories other than /var/lib/libvirt for kvm files, set the selinux context. In this example I use /vm to store my disk image files.
semanage fcontext -a -t virt_image_t "/vm(/.*)?"; restorecon -R /vm 

Allow packet forwarding between interfaces.
sed -i 's/^\(net.ipv4.ip_forward =\).*/\1 1/' /etc/sysctl.conf; sysctl -p 

Configure libvirtd service to start automatically and reboot.
chkconfig libvirtd on; shutdown -r now

Optionally you can set up bridging which will allow guests to have a network adaptor on the same physical lan as the host. In this example eth0 is the device to support the bridge and br0 will be the new device.
chkconfig network on
service network restart
yum -y erase NetworkManager
cp -p /etc/sysconfig/network-scripts/ifcfg-{eth0,br0}
sed -i -e'/HWADDR/d' -e'/UUID/d' -e's/eth0/br0/' -e's/Ethernet/Bridge/' \
/etc/sysconfig/network-scripts/ifcfg-br0
echo DELAY=0 >> /etc/sysconfig/network-scripts/ifcfg-br0
echo 'BOOTPROTO="none"' >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo BRIDGE=br0 >> /etc/sysconfig/network-scripts/ifcfg-eth0
service network restart
brctl show

The host is now ready to start creating kvm guests.

2. Guest Setup


Since there are many options for setting up a guest, it is easier to have variables collect the information which will be used in a single command to create the guest. Several options are shown, and most can be adjusted as needed.
Start by reviewing the available OS variants.
virt-install --os-variant=list | more

Select one of the OS options:
OS="--os-variant=freebsd8"
OS="--os-variant=win7"
OS="--os-variant=win7 --disk path=/var/lib/libvirt/iso/virtio-win.iso,device=cdrom"
OS="--os-variant=win2k8"
OS="--os-variant=win2k8 --disk path=/var/lib/libvirt/iso/virtio-win.iso,device=cdrom"
OS="--os-variant=rhel6"
OS="--os-variant=rhel7" 

Select a network option, replacing the MAC address if needed:
Net="--network bridge=br0"
Net="--network model=virtio,bridge=br0"
Net="--network model=virtio,mac=52:54:00:00:00:00"
Net="--network model=virtio,bridge=br0,mac=52:54:00:00:00:00"

Select a disk option, replacing the filename and size with desired values:
Disk="--disk /vm/Name.img,size=8"
Disk="--disk /var/lib/libvirt/images/Name.qcow2,size=4"
Disk="--disk /var/lib/libvirt/images/Name.qcow2,sparse=false,size=8"
Disk="--disk /var/lib/libvirt/images/Name.qcow2,sparse=false,bus=virtio,size=8"
Disk="--disk vol=pool/volume"
Disk="--livecd --nodisks"
Disk="--disk /dev/mapper/vg_..."

Select a source (live cd iso, pxe or url):
Src="--cdrom=/var/lib/libvirt/iso/CentOS-6.6-x86_64.iso"
Src="--pxe"
Src="-l http://alt.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/os/"
Src="-l http://download.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/os/"
Src="-l http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/
Src="-l http://ftp.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/"
Src="-l http://download.opensuse.org/distribution/openSUSE-stable/repo/oss/"
Src="--location=http://mirror.centos.org/centos/6/os/x86_64"

Optionally add a URL for a kickstart file:
KS=""
KS="-x ks=http://ks.example.com/kickstart/c6-64.ks"

Optionally select a graphics option:
Gr=""
Gr="--graphics none"
Gr="--graphics vnc"
Gr="--graphics vnc,password=foo"
Gr="--graphics spice"

Select number of cpus:
Cpu="--vcpus=1"
Cpu="--vcpus=2"
Cpu="--vcpus=4"

Select amount of ram:
Ram="--ram=512" 
Ram="--ram=768"
Ram="--ram=1024"
Ram="--ram=2048"

Choose a name for the guest:
Name="myguest"

Create the guest:
virt-install $OS $Net $KS $Disk $Src $Gr $Cpu $Ram --name=$Name --cpu host --arch=x86_64

*If you got an error like MP-BIOS 8254 timer or host CPU does not support feature cx16, then you need --cpu host --arch=x86_64 option to solve these problems.

Note that it could take a considerable amount of time to complete, especially if you have chosen a large, non-sparse disk file on a slow harddrive. If you have selected an interactive installation, you will need to connect to the console to complete the installation.
*Connect to the console, using myhost as an example host:
virt-viewer --connect qemu_ssh://myhost/$Name

*Start the virtual OS:
virsh --connect qemu:///system start myhost

*If you would prefer a gui application:
virt-manager &

*Finally, you can set up this guest to start automatically whenever the host is booted:
virsh autostart $Name

3. Interact with your virtual guest OS


To view the running guest servers:
#virsh list -all

From your own desktop (with GUI), to establish a SSH tunnel for VNC connection to guest OS:

#ssh -X someuser@x.x.x.x -L 5900:127.0.0.1:5900

where x.x.x.x is the ip of the KVM host OS, who is hosting your guest OS. The VNC connection is running on port 5900 on your KVM host. Then:

#virt-manager &

If you are not using a kickstart file, then you need to interact with the guest OS. You may do it through VNC on KVM host after SSH-tunneling as shown above (remember to turn on ssh X11 forwarding on KVM host):
 
#yum install vnc-server
#virsh list --all
#virsh list --uuid
#virsh-viewer mygest 

#virsh shutdown myguest
#virsh start myguest
 
To edit the XML settings of the virtual guest: 
 
#virsh edit myguest 

If you like to automate the installation of guest OS, please use a kickstart file.

--------------------------------------------------------------------------------------
To modify the XML file for virtual guests:
 virsh -c qemu:///session dumpxml myguest > ~/myguest.xml

Now you can edit this xml file (this trick didn't work in my case, though):
From   
<devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/storage/vmimages/Windows7_x64-01/qcow2-60GB_HDD1.qcow2'/>
      <target dev='hda' bus='ide'/>
    </disk>
To
<devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/storage/vmimages/Windows7_x64-01/qcow2-60GB_HDD1.qcow2'/>
      <target dev='hda' bus='ide'/>
    </disk>


Open virt-manager and delete the virtual guest, but keep the image file on disk.

Then, place the modified XML file back:
virsh -c qemu:///session define ~/myguest.xml

Now this virtual guest will show up again in virt-manager.
Start it!

When you have a reboot failure from virtual hard drive

(i)Use .qcow2 as an extension of virtual disk file.
(ii)Do not use bridging. (NAT)
Net="--network model=virtio,network=default"
Then I got it rebootable on my machine.
DSL will not connect to network, but CentOS6 connected to LAN/WAN with no problem (CentOS6 was using a local VLAN on KVM host though, NAT)

3. Import from an existing virtual guest


 % virsh destroy myguest
 % virsh undefine myguest
 % virt-install --connect qemu:///system --ram 1024 -n rhel_64 -r 2048 --os-type=linux --os-variant=rhel5  --disk path=/root/RHEL-Server-5.8-64-virtio.qcow2,device=disk,bus=virtio,format=qcow2 --vcpus=2 --vnc --noautoconsole --import

where your existing virtual guest is provided by /root/RHEL-Server-5.8-64-virtio.qcow2. A new VM will be built on it.

-------------------------------------------------------------------------------------
Thanks goes to ScottRobbins who contributed this guide. An earlier version of this article is found at http://home.roadrunner.com/~computertaijutsu/centoskvm.html