Description:

  • Example buoyant density distributions for 4 bacteria taxa
  • Making histograms of example taxa used for 16S region GC conservation figure

      "Clostridium ljungdahlii DSM 13528",
      "Escherichia coli APEC O78",
      "Streptomyces griseus subsp griseus\nNBRC 13350",
      "Lactobacillus gasseri ATCC 33323"
  • Plotting GC content for amplicons & shotgun reads

parsing out just taxa of interest from read GC files

amplicons

@ system76-server:~/notebook/deltaGC_notes/data/amplicon/140411_allBac/amp454-L215-N1k/140425_example-taxa

  • made a file of all 4 taxa

    • taxa_list.txt

      $ head -n 1 ../skewnorm_m10k_r4k-11.5k.txt > skewnorm_m10k_r4k-11.5k_exp.txt; grep -f taxa_list.txt ../skewnorm_m10k_r4k-11.5k.txt >> skewnorm_m10k_r4k-11.5k_exp.txt

      $ head -n 1 ../skewnorm_m15k_r4k-20k.txt > skewnorm_m15k_r4k-20k_exp.txt; grep -f taxa_list.txt ../skewnorm_m15k_r4k-20k.txt >> skewnorm_m15k_r4k-20k_exp.txt

metagenomes

@ system76-server:~/notebook/deltaGC_notes/data/mg-reads/140411_allBac/mg454-L215-N10k/140425_example-taxa

$ cp ~/notebook/deltaGC_notes/data/amplicon/140411_allBac/amp454-L215-N1k/140425_example-taxa/taxa_list.txt .

$ head -n 1 ../skewnorm_m10k_r4k-11.5k.txt > skewnorm_m10k_r4k-11.5k_exp.txt; grep -f taxa_list.txt ../skewnorm_m10k_r4k-11.5k.txt >> skewnorm_m10k_r4k-11.5k_exp.txt

$ head -n 1 ../skewnorm_m15k_r4k-20k.txt > skewnorm_m15k_r4k-20k_exp.txt; grep -f taxa_list.txt ../skewnorm_m15k_r4k-20k.txt >> skewnorm_m15k_r4k-20k_exp.txt

In [1]:
%load_ext rmagic
%load_ext rpy2.ipython


/opt/anaconda/lib/python2.7/site-packages/pytz/__init__.py:29: UserWarning: Module argparse was already imported from /opt/anaconda/lib/python2.7/argparse.pyc, but /opt/anaconda/lib/python2.7/site-packages is being added to sys.path
  from pkg_resources import resource_stream

In [2]:
%%R
# loading tables
require(ggplot2)
require(data.table)
require(gridExtra)


Loading required package: ggplot2
Loading required package: data.table
data.table 1.9.2  For help type: help("data.table")
Loading required package: gridExtra
Loading required package: grid

Loading amplicon deltaGC data


In [3]:
%%R
base.dir = "~/notebook/deltaGC_notes/data/amplicon/140411_allBac/amp454-L215-N1k/140425_example-taxa";
files = c(
    'skewnorm_m15k_r4k-20k_exp',
    'skewnorm_m10k_r4k-11.5k_exp'
    )

tbl.l = list()
for(i in files){
    in.file = paste(c(i, "txt"), collapse=".")
    in.file = paste(c(base.dir, in.file), collapse="/")
    tbl.l[[i]] = fread(in.file, header=T, sep="\t")
    tbl.l[[i]]$file = rep(i, nrow(tbl.l[[i]]))
    }

tbl.amp = do.call(rbind, tbl.l)

Loading shotgun read deltaGC data


In [4]:
%%R
base.dir = "~/notebook/deltaGC_notes/data/mg-reads/140411_allBac/mg454-L215-N10k/140425_example-taxa/";
files = list(
    'skewnorm_m15k_r4k-20k_exp',
    'skewnorm_m10k_r4k-11.5k_exp'
    )

tbl.l = list()
for(i in files){
    in.file = paste(c(i, "txt"), collapse=".")
    in.file = paste(c(base.dir, in.file), collapse="/")
    tbl.l[[i]] = fread(in.file, header=T, sep="\t")
    tbl.l[[i]]$file = rep(i, nrow(tbl.l[[i]]))
    }

tbl.mg = do.call(rbind, tbl.l)

Merging tables


In [5]:
%%R
# merging tables
tbl.amp[, dataset:= 'amplicon']
tbl.mg[, dataset:= 'shotgun']
tbl = rbind(tbl.amp, tbl.mg)

# editting values for plotting
tbl[, file:= gsub(".+m15k.+", "12.5 kb", file)]
tbl[, file:= gsub(".+m10k.+", "6 kb", file)]

## editing names
examples = c(
"Clostridium_ljungdahlii_DSM_13528",
"Escherichia_coli_APEC_O78",
"Streptomyces_griseus_subsp_griseus_NBRC_13350",  
"Lactobacillus_gasseri_ATCC_33323"
)
new.names = c(
"C. ljungdahlii",
"E. coli",
"S. griseus",
"L. gasseri"
)
for(i in 1:length(examples)){
    tbl$genome = gsub(examples[i], new.names[i], tbl$genome)
    }

# ordering of taxa
tbl$genome = factor(tbl$genome, levels=new.names)

# renaming 'dataset' to 'Fragments'
tbl[, Fragments := dataset]
tbl[, dataset := NULL]


           genome scaffold           read  read_GC read_buoyant_density
    1: L. gasseri CP000413  CP000413__418 52.55814             1.711507
    2: L. gasseri CP000413  CP000413__419 52.55814             1.711507
    3: L. gasseri CP000413  CP000413__412 52.55814             1.711507
    4: L. gasseri CP000413  CP000413__413 50.69767             1.709684
    5: L. gasseri CP000413  CP000413__410 50.69767             1.709684
   ---                                                                 
87996: S. griseus AP009493 AP009493__2047 60.46512             1.719256
87997: S. griseus AP009493 AP009493__2040 67.90698             1.726549
87998: S. griseus AP009493 AP009493__2041 70.23256             1.728828
87999: S. griseus AP009493 AP009493__2042 74.88372             1.733386
88000: S. griseus AP009493 AP009493__2043 79.06977             1.737488
       read_start read_length fragment_GC fragment_buoyant_density
    1:    3119592         215    49.50342                 1.708513
    2:    3585673         215    44.56862                 1.703677
    3:    3119592         215    46.30809                 1.705382
    4:     956257         215    44.01671                 1.703136
    5:    3132922         215    45.14824                 1.704245
   ---                                                            
87996:   15593419         215    73.57766                 1.732106
87997:   13676810         215    72.12288                 1.730680
87998:   15347106         215    70.99312                 1.729573
87999:   14283447         215    75.82455                 1.734308
88000:   10458701         215    75.74225                 1.734227
       fragment_start fragment_length    file Fragments
    1:        3119429           12284 12.5 kb  amplicon
    2:        3579137           14048 12.5 kb  amplicon
    3:        3108785           14911 12.5 kb  amplicon
    4:         951661           10053 12.5 kb  amplicon
    5:        3126169           12109 12.5 kb  amplicon
   ---                                                 
87996:       15591128            5730    6 kb   shotgun
87997:       13675673            6543    6 kb   shotgun
87998:       15345649            6102    6 kb   shotgun
87999:       14282870            5882    6 kb   shotgun
88000:       10455814            6130    6 kb   shotgun

Adding whole genome G+C content


In [6]:
%%R

# loading in genome GC table
tbl.genGC = fread("~/notebook/deltaGC_notes/data/genome_data/prok-bac-genomes_Ngaps_GC/prok-bac-genomes_Ngaps_GC.txt",
                    header=F)
## editing table
colnames(tbl.genGC) = c('genome', 'genome_GC')
tbl.genGC[,genome:=gsub(".+\\/|\\.fasta", "", genome)]

## selecting taxa of interest
examples = c(
"Clostridium_ljungdahlii_DSM_13528",
"Escherichia_coli_APEC_O78",
"Streptomyces_griseus_subsp_griseus_NBRC_13350",  
"Lactobacillus_gasseri_ATCC_33323"
)

tbl.genGC = subset(tbl.genGC, genome %in% examples)


## changing names
new.names = c(
"C. ljungdahlii",
"E. coli",
"S. griseus",
"L. gasseri"
)

for(i in 1:length(examples)){
    tbl.genGC$genome = gsub(examples[i], new.names[i], tbl.genGC$genome)
}


## calculating BD for each
tbl.genGC[, BD:= 0.098 * genome_GC + 1.66]


           genome genome_GC       BD
1:     S. griseus 0.7222741 1.730783
2:        E. coli 0.5068013 1.709667
3: C. ljungdahlii 0.3059600 1.689984
4:     L. gasseri 0.3468158 1.693988

In [21]:
%%R -w 7 -h 6 -u in
## plotting with mean GC
tbl1 = subset( tbl , file='12.5 kb' )

# plotting
p = ggplot(tbl1, aes(fragment_buoyant_density, fill=Fragments)) + 
        geom_density(alpha=0.5, size=0.4) +
        scale_fill_manual(values=c('blue', 'orange')) +
        facet_grid(genome ~ .) +
        geom_vline(data=tbl.genGC, aes(xintercept=BD), linetype='dashed') +
        labs(x=expression(paste("Fragment buoyant density (g ", ml^-1, ")")), 
             y="Kernel density") +
        theme( 
            text = element_text(size=18),
            axis.title.y = element_text(vjust=1),
            axis.title.x = element_text(vjust=0),
            axis.text.x = element_text(color='black'),
            axis.text.y = element_text(color='black'),           
            strip.text = element_text(face='italic'),
            strip.background = element_rect(size=4)
            )
ggsave("~/notebook/deltaGC_notes/data/amp-mg/figures/BD-dist_example-bac.tiff", 
          width=7, height=6, units='in', dpi=300)
print(p)
xxx=1