KasperSkytte / ampvis2

Tools for visualising microbial community amplicon data
https://kasperskytte.github.io/ampvis2/
GNU General Public License v3.0
67 stars 23 forks source link

unable to load ampvis2 package #90

Closed pradeepvirol closed 4 years ago

pradeepvirol commented 4 years ago

i installed the ampvis2 package using----install.packages("remotes") AND remotes::install_github("MadsAlbertsen/ampvis2")-- BUT getting following message

Error: Failed to install 'ampvis2' from GitHub: (converted from warning) installation of package ‘C:/Users/PRADEE~1/AppData/Local/Temp/RtmpI1af2a/fileeb04f776e1b/ampvis2_2.6.0.tar.gz’ had non-zero exit status In addition: Warning messages: 1: In untar2(tarfile, files, list, exdir) : skipping pax global extended headers 2: In untar2(tarfile, files, list, exdir) : skipping pax global extended headers 3: In untar2(tarfile, files, list, exdir) : skipping pax global extended headers 4: In untar2(tarfile, files, list, exdir) : skipping pax global extended headers

library(ampvis2) Error in library(ampvis2) : there is no package called ‘ampvis2’

pradeepvirol commented 4 years ago

i want to represent my data like below image

journal pntd 0006737 g003

pradeepvirol commented 4 years ago

kindly help in the above issue

KasperSkytte commented 4 years ago

Hi there. I will need the full output after you executed the install command. Seems to me you either have a broken R library or missing some system requirements.

pradeepvirol commented 4 years ago

Sir, thanks for the reply. after online search, trial & error, i could install and load ampvis2. However, I need to prepare the same heatmap as above for my data, but unable to understand the data set format. Can u help me.

KasperSkytte commented 4 years ago

Sorry that would be quite a service for me to do. You can try using amp_heatmap() and see if you can make something similar. Making something exactly like that requires you to learn how to wrangle with data and use ggplot2 to produce the plot. But you can make a heatmap for the 12 months, and then another one for the total (by making a metadata variable with one same value for all samples, fx "total", then use the group_by argument), and then stitch the two plots together with the patchwork package. You can see example data format with example_metadata and example_otutable after loading ampvis2. Here's a quick example:

library(ampvis2)
#> Loading required package: ggplot2
library(patchwork)

#example data
ampvis2::example_metadata
#> # A tibble: 8 x 4
#>   SampleID    Plant     Date                 Year
#>   <chr>       <chr>     <dttm>              <dbl>
#> 1 16SAMP_3893 Aalborg E 2014-02-06 00:00:00  2014
#> 2 16SAMP_3913 Aalborg E 2014-07-03 00:00:00  2014
#> 3 16SAMP_3941 Aalborg E 2014-08-19 00:00:00  2014
#> 4 16SAMP_3946 Aalborg E 2014-11-13 00:00:00  2014
#> 5 16SAMP_3953 Aalborg W 2014-02-04 00:00:00  2014
#> 6 16SAMP_4591 Aalborg W 2014-05-05 00:00:00  2014
#> 7 16SAMP_4597 Aalborg W 2014-08-18 00:00:00  2014
#> 8 16SAMP_4603 Aalborg W 2014-11-12 00:00:00  2014
ampvis2::example_otutable
#>        16SAMP_3893 16SAMP_3913 16SAMP_3941 16SAMP_3946 16SAMP_3953 16SAMP_4591
#> OTU_1           23          15         273          51         127         190
#> OTU_2          675         565         331         411         430         780
#> OTU_3          780         733         405         199        1346        1114
#> OTU_4          272         233        1434         256         736        1338
#> OTU_5          560         339         509         598         223         145
#> OTU_6          906         766         133         390         232        1458
#> OTU_7          297         218         418         130        1354         198
#> OTU_8           28           8         155          72         156         101
#> OTU_9            0           0           9           0          19          25
#> OTU_10         373         256          19         415          43         102
#>        16SAMP_4597 16SAMP_4603     Kingdom            Phylum
#> OTU_1          220          83 k__Bacteria    p__Chloroflexi
#> OTU_2          699         820 k__Bacteria p__Actinobacteria
#> OTU_3         1630         112 k__Bacteria p__Actinobacteria
#> OTU_4         1224         564 k__Bacteria p__Proteobacteria
#> OTU_5          212        1619 k__Bacteria    p__Chloroflexi
#> OTU_6          560         287 k__Bacteria     p__Firmicutes
#> OTU_7          283         116 k__Bacteria p__Actinobacteria
#> OTU_8          151          25 k__Bacteria    p__Nitrospirae
#> OTU_9           58           0 k__Bacteria  p__Bacteroidetes
#> OTU_10          73         138 k__Bacteria  p__Bacteroidetes
#>                        Class                 Order                Family
#> OTU_1              c__SJA-15           o__C10_SB1A           f__C10_SB1A
#> OTU_2      c__Actinobacteria      o__Micrococcales f__Intrasporangiaceae
#> OTU_3      c__Acidimicrobiia   o__Acidimicrobiales    f__Microthricaceae
#> OTU_4  c__Betaproteobacteria      o__Rhodocyclales     f__Rhodocyclaceae
#> OTU_5        c__Anaerolineae     o__Anaerolineales    f__Anaerolineaceae
#> OTU_6             c__Bacilli    o__Lactobacillales  f__Carnobacteriaceae
#> OTU_7      c__Acidimicrobiia   o__Acidimicrobiales    f__Microthricaceae
#> OTU_8          c__Nitrospira      o__Nitrospirales     f__Nitrospiraceae
#> OTU_9    c__Sphingobacteriia o__Sphingobacteriales     f__Saprospiraceae
#> OTU_10   c__Sphingobacteriia o__Sphingobacteriales     f__Saprospiraceae
#>                              Genus         Species
#> OTU_1     g__Candidatus Amarilinum             s__
#> OTU_2              g__Tetrasphaera             s__
#> OTU_3     g__Candidatus Microthrix             s__
#> OTU_4             g__Dechloromonas             s__
#> OTU_5  g__Candidatus Villogracilis             s__
#> OTU_6              g__Trichococcus             s__
#> OTU_7     g__Candidatus Microthrix             s__
#> OTU_8                g__Nitrospira s__sublineage I
#> OTU_9                 g__QEDR3BF09             s__
#> OTU_10                     g__MK04             s__

#load example data
d <- amp_load(
  otutable = example_otutable,
  metadata = example_metadata
)

#brief summary of data
d
#> ampvis2 object with 3 elements. 
#> Summary of OTU table:
#>      Samples         OTUs  Total#Reads    Min#Reads    Max#Reads Median#Reads 
#>            8           10        32246         2522         5451         3839 
#>    Avg#Reads 
#>      4030.75 
#> 
#> Assigned taxonomy:
#>  Kingdom   Phylum    Class    Order   Family    Genus  Species 
#> 10(100%) 10(100%) 10(100%) 10(100%) 10(100%) 10(100%)   1(10%) 
#> 
#> Metadata variables: 4 
#>  SampleID, Plant, Date, Year

#basic heatmap
heatmap <- amp_heatmap(d)
heatmap


#make a combined plot with total
#first add a metadata variable with "total" in all cells
d$metadata$total <- "Total"

#then make a heatmap with one column "total", and remove y axis text and tickmarks
heatmap_total <- amp_heatmap(d, group_by = "total") +
  theme(axis.text.y = element_blank(),
        axis.ticks.y = element_blank())
heatmap_total


#combine the two plots into one plot with patchwork (simply use +)
heatmap + heatmap_total + plot_layout(nrow = 1, widths = c(9,1))

Created on 2020-04-27 by the reprex package (v0.3.0)

pradeepvirol commented 4 years ago

Thank you very much sir for your detail reply. I will try it with my data. Thanks once again.