SampleID not found

Please i want to understand why i keep getting this errors and how i can fix them. i have seen some issues like these and followed how they solved them but mine seem not still working. i will be glad with some help out here please. i have checked here but still wasn't solved. here are my codes.
metadata55<-readr::read_tsv("D:/Qiime222/New_metadata55.tsv")
uwunifrac<-read_qza("D:/Qiime222/unweighted_unifrac_pcoa_results.qza")
shannon<-read_qza("D:/Qiime222/shannon_vector.qza")$data %>% rownames_to_column("SampleID")
uwunifrac$data$Vectors %>%

  • + select(SampleID, PC1, PC2) %>%
    
  • + left_join(metadata55) %>%
    
  • + left_join(shannon) %>%
    
  • + ggplot(aes(x=PC1, y=PC2, color=`Period`, shape=`Treatment`, size=shannon)) + geom_point(alpha=0.5) + theme_q2r() + scale_shape_manual(values=c(16,1), name="Treatment") + scale_size_continuous(name="Shannon Diversity") + scale_color_discrete(name="Period") + stat_ellipse()
    

Error in select(SampleID, PC1, PC2) : object 'SampleID' not found

Also i had another here.
SVs <-read_qza("D:/Qiime222/BacAr_filter_table.qza")
taxonomy<-read_qza("D:/Qiime222/gg_taxonomy.qza")
SVs<-apply(SVs, 2, function(x) x/sum*100)
Error in apply(SVs, 2, function(x) x/sum * 100) :
dim(X) must have a positive length.
and here

SVsToPlot<-

data.frame(MeanAbundance=rowMeans(SVs)) %>%


* rownames_to_column("Feature.ID") %>%
* arrange(desc(MeanAbundance)) %>%
* top_n(30, MeanAbundance) %>%
* pull(Feature.ID)
Error in rowMeans(SVs) : 'x' must be an array of at least two dimensions

When I see this kind of "not found" error, I check and see that it's missing somewhere it needs to be. See if this example helps.

suppressPackageStartupMessages({
  library(dplyr)
  library(tibble)
})
mtcars <- mtcars %>% rownames_to_column(var = "Automobile")
# confirm that column exists
"Automobile" %in% colnames(mtcars)
#> [1] TRUE
# create fake data
fake <- sample(1:100,32,replace=FALSE)

# create data frame
added <- data.frame(Automobile = mtcars$Automobile, fake)
# confirm that column exists
"Automobile" %in% colnames(added)
#> [1] TRUE

result <- right_join(mtcars,added, by = "Automobile")

# show 
head(result)
#>          Automobile  mpg cyl disp  hp drat    wt  qsec vs am gear carb fake
#> 1         Mazda RX4 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4   89
#> 2     Mazda RX4 Wag 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4    4
#> 3        Datsun 710 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1   41
#> 4    Hornet 4 Drive 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1   55
#> 5 Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2   62
#> 6           Valiant 18.1   6  225 105 2.76 3.460 20.22  1  0    3    1   72

Thank you for your time and swift response. i have doubled checked the imported files to check the names of the column and they seem fine. take a look please.

Hi, it might help if you provide a reproducible example rather than screenshots that people can't work with.

The error seems to be in here:

uwunifrac$data$Vectors %>%
 select(SampleID, PC1, PC2)

You should provide a reprex of uwunifrac and/or uwunifrac$data$Vectors.

Without the reprex, I can't check, but it appears that the SampleID field is in shannon, not in uwunifrac$data$Vectors.

library(qiime2R)
library(tidyverse)
library(datapasta)
library(wrapr)
#> 
#> Attaching package: 'wrapr'
#> The following object is masked from 'package:dplyr':
#> 
#>     coalesce
#> The following objects are masked from 'package:tidyr':
#> 
#>     pack, unpack
#> The following object is masked from 'package:tibble':
#> 
#>     view
metadata55<-readr::read_tsv("D:/Qiime222/New_metadata55.tsv")
#> Rows: 21 Columns: 11
#> -- Column specification --------------------------------------------------------
#> Delimiter: "\t"
#> chr (3): SampleID, Treatment, Period
#> dbl (8): pH, Alkalinity_g CaCO3/kg, TAN(g N/kg), TVFAs_g/kg, TS, VS, daily_m...
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
uwunifrac<-read_qza("D:/Qiime222/unweighted_unifrac_pcoa_results.qza")
shannon<-read_qza("D:/Qiime222/shannon_vector.qza")$data %>% rownames_to_column("SampleID")
datapasta::tribble_paste(metadata55)
#> tibble::tribble(
#>    ~SampleID, ~Treatment,  ~Period,  ~pH, ~Alkalinity_g.CaCO3.kg, ~TAN.g.N.kg., ~TVFAs_g.kg,   ~TS,   ~VS, ~daily_methane_yield_L.k.kgVS, ~cummulative_methane_yeild_L.kgVS,
#>    "S1A0-0d",    "S1-A0",   "0day", 8.42,                   9.12,         3.27,        0.38, 17.83, 14.41,                             0,                                 0,
#>   "S1A0-30d",    "S1-A0", "30days",  8.2,                  11.48,         3.39,           0, 14.58, 10.93,                          2.57,                            190.47,
#>    "S3A0-0d",    "S3-A0",   "0day", 8.65,                   9.21,         2.88,        1.01, 17.57, 14.36,                             0,                                 0,
#>   "S3A0-30d",    "S3-A0", "30days", 8.43,                  11.49,         3.15,        0.82, 14.37, 10.86,                           3.5,                            186.38,
#>    "S3A3-0d",    "S3-A3",   "0day", 8.76,                   9.22,         2.78,        0.82, 18.12, 14.91,                             0,                                 0,
#>   "S3A3-30d",    "S3-A3", "30days", 8.57,                  11.22,          3.2,        0.32,    14, 10.48,                          4.14,                               193,
#>    "S3A7-0d",    "S3-A7",   "0day", 8.72,                   9.92,         2.98,        0.57,  18.4, 14.96,                             0,                                 0,
#>   "S3A7-30d",    "S3-A7", "30days", 8.58,                  12.49,         3.46,        0.11,  14.6, 10.99,                           2.9,                            196.75,
#>    "S6A0-0d",     "S6A0",   "0day", 8.64,                   7.97,         2.27,         0.8, 18.21, 14.74,                             0,                                 0,
#>   "S6A0-30d",     "S6A0", "30days", 8.31,                  10.12,         2.67,        0.95,  15.7, 12.03,                          3.31,                            160.21,
#>    "S6A3-0d",    "S6-A3",   "0day", 8.63,                   8.11,         2.18,        1.36, 18.18, 14.57,                             0,                                 0,
#>   "S6A3-30d",    "S6-A3", "30days",  8.3,                  10.32,         2.41,        0.38, 15.38, 11.57,                          3.26,                            179.49,
#>    "S6A7-0d",    "S6-A7",   "0day", 8.65,                   8.31,            2,        0.55,    18, 14.64,                             0,                                 0,
#>   "S6A7-30d",    "S6-A7", "30days",  8.4,                   9.75,          2.4,        0.42, 15.87, 12.38,                          2.82,                            146.44,
#>    "S1A0-ef",  "S1A0-ef",    "Eff", 8.42,                  11.42,         3.69,        0.15,  7.43,  4.29,                            NA,                                NA,
#>    "S3A0-ef",  "S3A0-ef",    "Eff", 8.24,                  11.82,         4.04,        0.56,     7,  3.98,                            NA,                                NA,
#>    "S3A3-ef",  "S3A3-ef",    "Eff",  8.2,                  12.28,         3.73,        0.17,  7.12,  4.06,                            NA,                                NA,
#>    "S3A7-ef",  "S3A7-ef",    "Eff",  8.2,                     12,          3.4,        0.16,   7.5,  4.26,                            NA,                                NA,
#>    "S6A0-ef",  "S6A0-ef",    "Eff", 8.21,                  10.33,         2.96,        0.32,  7.31,  4.18,                            NA,                                NA,
#>    "S6A3-ef",  "S6A3-ef",    "Eff", 8.16,                  10.29,         2.97,        0.56,  7.42,  4.24,                            NA,                                NA,
#>    "S6A7-ef",  "S6A7-ef",    "Eff", 8.27,                  11.32,         3.28,        0.27,   7.3,  4.18,                            NA,                                NA
#>   )
datapasta::tribble_paste(shannon)
#> tibble::tribble(
#>    ~SampleID, ~shannon_entropy,
#>    "S1A0-0d", 6.10277331636607,
#>   "S1A0-30d", 6.59613138576861,
#>    "S1A0-ef", 6.10867894104666,
#>    "S3A0-0d", 6.22192294521463,
#>   "S3A0-30d", 6.28071927382113,
#>    "S3A0-ef", 6.01221409333534,
#>    "S3A3-0d",  5.9418718366662,
#>   "S3A3-30d", 5.96527875223599,
#>    "S3A3-ef", 6.31622270518156,
#>    "S3A7-0d", 6.11400491959082,
#>   "S3A7-30d", 6.31568415836149,
#>    "S3A7-ef", 6.27747243703584,
#>    "S6A0-0d",  5.8280489921665,
#>   "S6A0-30d", 5.93570953768047,
#>    "S6A0-ef", 6.14019272162196,
#>    "S6A3-0d", 6.49012232199792,
#>   "S6A3-30d", 6.41099932787163,
#>    "S6A3-ef",  6.0928169310324,
#>    "S6A7-0d",  5.9845666413645,
#>   "S6A7-30d", 6.35907882878743,
#>    "S6A7-ef", 5.92447790699498
#>   )
datapasta::tribble_paste(uwunifrac)
#> Could not format input_table as table. Unexpected class.

Created on 2021-11-19 by the reprex package (v2.0.1)

Can you have a look at the article on how to provide a reprex? We don't have your datasets so can't read in your files.

1 Like

Hi, i have tried to follow the tutorial to create a reprex, but the uwunifrac seem not to open. can you take a look please. Thanks for your time.

library(qiime2R)
library(tidyverse)
library(datapasta)
library(wrapr)
#> 
#> Attaching package: 'wrapr'
#> The following object is masked from 'package:dplyr':
#> 
#>     coalesce
#> The following objects are masked from 'package:tidyr':
#> 
#>     pack, unpack
#> The following object is masked from 'package:tibble':
#> 
#>     view
metadata55<-readr::read_tsv("D:/Qiime222/New_metadata55.tsv")
#> Rows: 21 Columns: 11
#> -- Column specification --------------------------------------------------------
#> Delimiter: "\t"
#> chr (3): SampleID, Treatment, Period
#> dbl (8): pH, Alkalinity_g CaCO3/kg, TAN(g N/kg), TVFAs_g/kg, TS, VS, daily_m...
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
uwunifrac<-read_qza("D:/Qiime222/unweighted_unifrac_pcoa_results.qza")
shannon<-read_qza("D:/Qiime222/shannon_vector.qza")$data %>% rownames_to_column("SampleID")
datapasta::tribble_paste(metadata55)
#> tibble::tribble(
#>    ~SampleID, ~Treatment,  ~Period,  ~pH, ~Alkalinity_g.CaCO3.kg, ~TAN.g.N.kg., ~TVFAs_g.kg,   ~TS,   ~VS, ~daily_methane_yield_L.k.kgVS, ~cummulative_methane_yeild_L.kgVS,
#>    "S1A0-0d",    "S1-A0",   "0day", 8.42,                   9.12,         3.27,        0.38, 17.83, 14.41,                             0,                                 0,
#>   "S1A0-30d",    "S1-A0", "30days",  8.2,                  11.48,         3.39,           0, 14.58, 10.93,                          2.57,                            190.47,
#>    "S3A0-0d",    "S3-A0",   "0day", 8.65,                   9.21,         2.88,        1.01, 17.57, 14.36,                             0,                                 0,
#>   "S3A0-30d",    "S3-A0", "30days", 8.43,                  11.49,         3.15,        0.82, 14.37, 10.86,                           3.5,                            186.38,
#>    "S3A3-0d",    "S3-A3",   "0day", 8.76,                   9.22,         2.78,        0.82, 18.12, 14.91,                             0,                                 0,
#>   "S3A3-30d",    "S3-A3", "30days", 8.57,                  11.22,          3.2,        0.32,    14, 10.48,                          4.14,                               193,
#>    "S3A7-0d",    "S3-A7",   "0day", 8.72,                   9.92,         2.98,        0.57,  18.4, 14.96,                             0,                                 0,
#>   "S3A7-30d",    "S3-A7", "30days", 8.58,                  12.49,         3.46,        0.11,  14.6, 10.99,                           2.9,                            196.75,
#>    "S6A0-0d",     "S6A0",   "0day", 8.64,                   7.97,         2.27,         0.8, 18.21, 14.74,                             0,                                 0,
#>   "S6A0-30d",     "S6A0", "30days", 8.31,                  10.12,         2.67,        0.95,  15.7, 12.03,                          3.31,                            160.21,
#>    "S6A3-0d",    "S6-A3",   "0day", 8.63,                   8.11,         2.18,        1.36, 18.18, 14.57,                             0,                                 0,
#>   "S6A3-30d",    "S6-A3", "30days",  8.3,                  10.32,         2.41,        0.38, 15.38, 11.57,                          3.26,                            179.49,
#>    "S6A7-0d",    "S6-A7",   "0day", 8.65,                   8.31,            2,        0.55,    18, 14.64,                             0,                                 0,
#>   "S6A7-30d",    "S6-A7", "30days",  8.4,                   9.75,          2.4,        0.42, 15.87, 12.38,                          2.82,                            146.44,
#>    "S1A0-ef",  "S1A0-ef",    "Eff", 8.42,                  11.42,         3.69,        0.15,  7.43,  4.29,                            NA,                                NA,
#>    "S3A0-ef",  "S3A0-ef",    "Eff", 8.24,                  11.82,         4.04,        0.56,     7,  3.98,                            NA,                                NA,
#>    "S3A3-ef",  "S3A3-ef",    "Eff",  8.2,                  12.28,         3.73,        0.17,  7.12,  4.06,                            NA,                                NA,
#>    "S3A7-ef",  "S3A7-ef",    "Eff",  8.2,                     12,          3.4,        0.16,   7.5,  4.26,                            NA,                                NA,
#>    "S6A0-ef",  "S6A0-ef",    "Eff", 8.21,                  10.33,         2.96,        0.32,  7.31,  4.18,                            NA,                                NA,
#>    "S6A3-ef",  "S6A3-ef",    "Eff", 8.16,                  10.29,         2.97,        0.56,  7.42,  4.24,                            NA,                                NA,
#>    "S6A7-ef",  "S6A7-ef",    "Eff", 8.27,                  11.32,         3.28,        0.27,   7.3,  4.18,                            NA,                                NA
#>   )
datapasta::tribble_paste(shannon)
#> tibble::tribble(
#>    ~SampleID, ~shannon_entropy,
#>    "S1A0-0d", 6.10277331636607,
#>   "S1A0-30d", 6.59613138576861,
#>    "S1A0-ef", 6.10867894104666,
#>    "S3A0-0d", 6.22192294521463,
#>   "S3A0-30d", 6.28071927382113,
#>    "S3A0-ef", 6.01221409333534,
#>    "S3A3-0d",  5.9418718366662,
#>   "S3A3-30d", 5.96527875223599,
#>    "S3A3-ef", 6.31622270518156,
#>    "S3A7-0d", 6.11400491959082,
#>   "S3A7-30d", 6.31568415836149,
#>    "S3A7-ef", 6.27747243703584,
#>    "S6A0-0d",  5.8280489921665,
#>   "S6A0-30d", 5.93570953768047,
#>    "S6A0-ef", 6.14019272162196,
#>    "S6A3-0d", 6.49012232199792,
#>   "S6A3-30d", 6.41099932787163,
#>    "S6A3-ef",  6.0928169310324,
#>    "S6A7-0d",  5.9845666413645,
#>   "S6A7-30d", 6.35907882878743,
#>    "S6A7-ef", 5.92447790699498
#>   )
datapasta::tribble_paste(uwunifrac)
#> Could not format input_table as table. Unexpected class.

Created on 2021-11-19 by the reprex package (v2.0.1)

is still opaque to us. Just cut and paste

str(uwunifrac)

to see what it's columns (and nested structure columns) look like.

Also just paste these bits for the reprex:

tibble::tribble(
     ~SampleID, ~shannon_entropy,
     "S1A0-0d", 6.10277331636607,
    "S1A0-30d", 6.59613138576861,
     "S1A0-ef", 6.10867894104666,
     "S3A0-0d", 6.22192294521463,
    "S3A0-30d", 6.28071927382113,
     "S3A0-ef", 6.01221409333534,
     "S3A3-0d",  5.9418718366662,
    "S3A3-30d", 5.96527875223599,
     "S3A3-ef", 6.31622270518156,
     "S3A7-0d", 6.11400491959082,
    "S3A7-30d", 6.31568415836149,
     "S3A7-ef", 6.27747243703584,
     "S6A0-0d",  5.8280489921665,
    "S6A0-30d", 5.93570953768047,
    "S6A0-ef", 6.14019272162196,
    "S6A3-0d", 6.49012232199792,
   "S6A3-30d", 6.41099932787163,
    "S6A3-ef",  6.0928169310324,
    "S6A7-0d",  5.9845666413645,
   "S6A7-30d", 6.35907882878743,
    "S6A7-ef", 5.92447790699498
   )

Here it is. I really appreciate. Thank you.

library(qiime2R)
library(tidyverse)
library(datapasta)
library(wrapr)
#> 
#> Attaching package: 'wrapr'
#> The following object is masked from 'package:dplyr':
#> 
#>     coalesce
#> The following objects are masked from 'package:tidyr':
#> 
#>     pack, unpack
#> The following object is masked from 'package:tibble':
#> 
#>     view
metadata55<-readr::read_tsv("D:/Qiime222/New_metadata55.tsv")
#> Rows: 21 Columns: 11
#> -- Column specification --------------------------------------------------------
#> Delimiter: "\t"
#> chr (3): SampleID, Treatment, Period
#> dbl (8): pH, Alkalinity_g CaCO3/kg, TAN(g N/kg), TVFAs_g/kg, TS, VS, daily_m...
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
uwunifrac<-read_qza("D:/Qiime222/unweighted_unifrac_pcoa_results.qza")
shannon<-read_qza("D:/Qiime222/shannon_vector.qza")$data %>% rownames_to_column("SampleID")
str(uwunifrac)
#> List of 7
#>  $ uuid      : chr "15b1a379-8b2a-46d9-83bf-493a8198b2d0"
#>  $ type      : chr "PCoAResults"
#>  $ format    : chr "OrdinationDirectoryFormat"
#>  $ contents  :'data.frame':  58 obs. of  4 variables:
#>   ..$ files.Name  : chr [1:58] "15b1a379-8b2a-46d9-83bf-493a8198b2d0/VERSION" "15b1a379-8b2a-46d9-83bf-493a8198b2d0/checksums.md5" "15b1a379-8b2a-46d9-83bf-493a8198b2d0/metadata.yaml" "15b1a379-8b2a-46d9-83bf-493a8198b2d0/data/ordination.txt" ...
#>   ..$ files.Length: num [1:58] 39 5632 95 9925 39 ...
#>   ..$ files.Date  : POSIXct[1:58], format: "2021-11-14 16:18:00" "2021-11-14 16:18:00" ...
#>   ..$ size        : num [1:58] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ version   :'data.frame':  3 obs. of  2 variables:
#>   ..$ V1: chr [1:3] "QIIME" "archive:" "framework:"
#>   ..$ V2: chr [1:3] "2" "5" "2021.4.0"
#>  $ data      :List of 3
#>   ..$ Eigvals            :'data.frame':  1 obs. of  21 variables:
#>   .. ..$ PC1 : num 0.56
#>   .. ..$ PC2 : num 0.206
#>   .. ..$ PC3 : num 0.196
#>   .. ..$ PC4 : num 0.164
#>   .. ..$ PC5 : num 0.15
#>   .. ..$ PC6 : num 0.106
#>   .. ..$ PC7 : num 0.0843
#>   .. ..$ PC8 : num 0.0768
#>   .. ..$ PC9 : num 0.0756
#>   .. ..$ PC10: num 0.0644
#>   .. ..$ PC11: num 0.0599
#>   .. ..$ PC12: num 0.0549
#>   .. ..$ PC13: num 0.0486
#>   .. ..$ PC14: num 0.0444
#>   .. ..$ PC15: num 0.0368
#>   .. ..$ PC16: num 0.0356
#>   .. ..$ PC17: num 0.0282
#>   .. ..$ PC18: num 0.0262
#>   .. ..$ PC19: num 0.0235
#>   .. ..$ PC20: num 0.0173
#>   .. ..$ PC21: num 0
#>   ..$ ProportionExplained:'data.frame':  1 obs. of  21 variables:
#>   .. ..$ PC1 : num 0.272
#>   .. ..$ PC2 : num 0.1
#>   .. ..$ PC3 : num 0.0951
#>   .. ..$ PC4 : num 0.0796
#>   .. ..$ PC5 : num 0.0731
#>   .. ..$ PC6 : num 0.0515
#>   .. ..$ PC7 : num 0.0409
#>   .. ..$ PC8 : num 0.0373
#>   .. ..$ PC9 : num 0.0367
#>   .. ..$ PC10: num 0.0313
#>   .. ..$ PC11: num 0.0291
#>   .. ..$ PC12: num 0.0267
#>   .. ..$ PC13: num 0.0236
#>   .. ..$ PC14: num 0.0216
#>   .. ..$ PC15: num 0.0179
#>   .. ..$ PC16: num 0.0173
#>   .. ..$ PC17: num 0.0137
#>   .. ..$ PC18: num 0.0127
#>   .. ..$ PC19: num 0.0114
#>   .. ..$ PC20: num 0.00842
#>   .. ..$ PC21: num 0
#>   ..$ Vectors            :'data.frame':  21 obs. of  22 variables:
#>   .. ..$ SampleID: chr [1:21] "S1A0-0d" "S1A0-30d" "S1A0-ef" "S3A0-0d" ...
#>   .. ..$ PC1     : num [1:21] -0.0576 0.1811 -0.074 -0.071 0.2362 ...
#>   .. ..$ PC2     : num [1:21] -0.08395 -0.13567 -0.14299 0.00742 -0.08371 ...
#>   .. ..$ PC3     : num [1:21] 0.0727 0.0262 0.0491 0.1672 0.033 ...
#>   .. ..$ PC4     : num [1:21] 0.0999 -0.0761 0.1647 -0.0889 -0.0836 ...
#>   .. ..$ PC5     : num [1:21] 0.03093 0.00555 0.07863 0.17278 -0.01878 ...
#>   .. ..$ PC6     : num [1:21] -0.0904 -0.0721 0.0739 -0.0156 0.0881 ...
#>   .. ..$ PC7     : num [1:21] 0.04908 0.01471 -0.14128 -0.07192 -0.00895 ...
#>   .. ..$ PC8     : num [1:21] 0.1193 -0.0203 -0.0341 0.0113 0.0022 ...
#>   .. ..$ PC9     : num [1:21] -0.01663 0.05704 0.0871 0.00376 -0.01337 ...
#>   .. ..$ PC10    : num [1:21] -0.09643 -0.10605 0.00262 0.07802 -0.01905 ...
#>   .. ..$ PC11    : num [1:21] -0.01487 0.0417 0.00259 -0.01651 0.05843 ...
#>   .. ..$ PC12    : num [1:21] 0.0415 -0.1377 0.03 -0.0354 0.0771 ...
#>   .. ..$ PC13    : num [1:21] -0.0117 -0.0226 -0.0726 0.0719 0.0151 ...
#>   .. ..$ PC14    : num [1:21] 0.01146 0.00741 -0.04392 0.04275 -0.00223 ...
#>   .. ..$ PC15    : num [1:21] -0.0391 -0.0179 0.0275 -0.0102 0.0452 ...
#>   .. ..$ PC16    : num [1:21] -0.057 0.0273 0.0285 -0.0114 -0.0922 ...
#>   .. ..$ PC17    : num [1:21] 0.00399 -0.027807 0.000162 -0.02612 -0.020352 ...
#>   .. ..$ PC18    : num [1:21] -0.01435 0.01073 -0.00219 -0.04927 0.05461 ...
#>   .. ..$ PC19    : num [1:21] 0.0562 -0.0242 0.0124 -0.0238 -0.0435 ...
#>   .. ..$ PC20    : num [1:21] -0.03292 0.01799 0.00581 -0.03511 -0.01499 ...
#>   .. ..$ PC21    : num [1:21] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ provenance:List of 13
#>   ..$ 15b1a379-8b2a-46d9-83bf-493a8198b2d0/provenance/artifacts/74bb6736-aae8-4ff6-b3a7-2f43a36bdb7d/action/action.yaml:List of 4
#>   .. ..$ execution   :List of 2
#>   .. .. ..$ uuid   : chr "6edca2d3-6058-4d32-8942-8b052f43b2cc"
#>   .. .. ..$ runtime:List of 3
#>   .. .. .. ..$ start   : chr "2021-11-14T16:18:40.881657+00:00"
#>   .. .. .. ..$ end     : chr "2021-11-14T16:18:40.903396+00:00"
#>   .. .. .. ..$ duration: chr "21739 microseconds"
#>   .. ..$ action      :List of 7
#>   .. .. ..$ type       : chr "method"
#>   .. .. ..$ plugin     : chr "environment:plugins:diversity"
#>   .. .. ..$ action     : chr "pcoa"
#>   .. .. ..$ inputs     :List of 1
#>   .. .. .. ..$ :List of 1
#>   .. .. .. .. ..$ distance_matrix: chr "4a9e79c3-5377-42d4-b4f2-40519b04f6fd"
#>   .. .. ..$ parameters :List of 1
#>   .. .. .. ..$ :List of 1
#>   .. .. .. .. ..$ number_of_dimensions: NULL
#>   .. .. ..$ output-name: chr "pcoa"
#>   .. .. ..$ citations  : chr [1:2] "action|diversity:2021.4.0|method:pcoa|0" "action|diversity:2021.4.0|method:pcoa|1"
#>   .. ..$ transformers:List of 2
#>   .. .. ..$ inputs:List of 1
#>   .. .. .. ..$ distance_matrix:List of 1
#>   .. .. .. .. ..$ :List of 3

tibble::tribble(
  ~SampleID, ~shannon_entropy,
  "S1A0-0d", 6.10277331636607,
  "S1A0-30d", 6.59613138576861,
  "S1A0-ef", 6.10867894104666,
  "S3A0-0d", 6.22192294521463,
  "S3A0-30d", 6.28071927382113,
  "S3A0-ef", 6.01221409333534,
  "S3A3-0d",  5.9418718366662,
  "S3A3-30d", 5.96527875223599,
  "S3A3-ef", 6.31622270518156,
  "S3A7-0d", 6.11400491959082,
  "S3A7-30d", 6.31568415836149,
  "S3A7-ef", 6.27747243703584,
  "S6A0-0d",  5.8280489921665,
  "S6A0-30d", 5.93570953768047,
  "S6A0-ef", 6.14019272162196,
  "S6A3-0d", 6.49012232199792,
  "S6A3-30d", 6.41099932787163,
  "S6A3-ef",  6.0928169310324,
  "S6A7-0d",  5.9845666413645,
  "S6A7-30d", 6.35907882878743,
  "S6A7-ef", 5.92447790699498
)
#> # A tibble: 21 x 2
#>    SampleID shannon_entropy
#>    <chr>              <dbl>
#>  1 S1A0-0d             6.10
#>  2 S1A0-30d            6.60
#>  3 S1A0-ef             6.11
#>  4 S3A0-0d             6.22
#>  5 S3A0-30d            6.28
#>  6 S3A0-ef             6.01
#>  7 S3A3-0d             5.94
#>  8 S3A3-30d            5.97
#>  9 S3A3-ef             6.32
#> 10 S3A7-0d             6.11
#> # ... with 11 more rows

Created on 2021-11-19 by the reprex package (v2.0.1)

Pull out this. I’m on a tablet, so I can’t check, but something like

pulled <- uwunifrac[7]

and you should be able to join on that.

hello @technocrat thank you for the sacrifices. it still showed this error:
Error in select(SampleID, PC1, PC2) : object 'SampleID' not found

the datapasta tools are good options when you want to share tabular data, but as your data is not tabular, they are inappropriate tools. A good general purpose fallback (that is described in the guide) is dput() function, which provides a string/text representation of your object . This is a much larger class of shareable objects than tabular (though it is not exhaustive and may be expected to fail on yet more complex objects which might involve things like environments and memory pointers and other exotica, but this is a long sidebar. ...
Suffice to say, dput() is worth trying when datapasta functions fail you. However, it may be that your object is quite large which might pose a challenge :frowning:

Simplifing further if you already know you want to zoom in on a target subset of uwunifrac then you can dput that component.
for example

dput(uwunifrac$data$vectors)

Thank you @nirgrahamuk this seem to have solved that problem but developed a new error. Thank you for your time.

library(qiime2R)
library(tidyverse)
library(datapasta)
library(wrapr)
#> 
#> Attaching package: 'wrapr'
#> The following object is masked from 'package:dplyr':
#> 
#>     coalesce
#> The following objects are masked from 'package:tidyr':
#> 
#>     pack, unpack
#> The following object is masked from 'package:tibble':
#> 
#>     view
metadata55<-readr::read_tsv("D:/Qiime222/New_metadata55.tsv")
#> Rows: 21 Columns: 11
#> -- Column specification --------------------------------------------------------
#> Delimiter: "\t"
#> chr (3): SampleID, Treatment, Period
#> dbl (8): pH, Alkalinity_g CaCO3/kg, TAN(g N/kg), TVFAs_g/kg, TS, VS, daily_m...
#> 
#> i Use `spec()` to retrieve the full column specification for this data.
#> i Specify the column types or set `show_col_types = FALSE` to quiet this message.
uwunifrac<-read_qza("D:/Qiime222/unweighted_unifrac_pcoa_results.qza")
shannon<-read_qza("D:/Qiime222/shannon_vector.qza")$data %>% rownames_to_column("SampleID")
dput(uwunifrac$data$vectors)%>%
uwunifrac$data$Vectors %>%
  +   +     + select(SampleID, PC1, PC2) %>%
  +   +     + left_join(metadata55) %>%
  +   +     + left_join(shannon) %>%
  +   +     + ggplot(aes(x=PC1, y=PC2, color=`Period`, shape=`Treatment`, size=shannon)) + geom_point(alpha=0.5) + theme_q2r() + scale_shape_manual(values=c(16,1), name="Treatment") + scale_size_continuous(name="Shannon Diversity") + scale_color_discrete(name="Period") + stat_ellipse()
#> Error in .$(uwunifrac$data): 3 arguments passed to '$' which requires 2

Created on 2021-11-19 by the reprex package (v2.0.1)

I think there may be a core misunderstanding, the purpose of dput and datapasta are to provide shareable representations of some data. It serves no purpose to pipe the result of that to anything. simply use the output of dput(uwunifrac$data$vectors) as what you share to us to represent what uwunifrac$data$vectors is , so that we have it also.

This will demonstrate one method of digging down into an object to discover where a particular object is.

suppressPackageStartupMessages({
  library(dplyr)
  library(tibble)
})
mtcars <- mtcars %>% rownames_to_column(var = "Automobile")
# confirm that column exists
"Automobile" %in% colnames(mtcars)
#> [1] TRUE
# create fake data
fake <- sample(1:100,32,replace=FALSE)

# create data frame
added <- data.frame(Automobile = mtcars$Automobile, fake)
# confirm that column exists
"Automobile" %in% colnames(added)
#> [1] TRUE

result <- right_join(mtcars,added, by = "Automobile")

# show 
head(result)
#>          Automobile  mpg cyl disp  hp drat    wt  qsec vs am gear carb fake
#> 1         Mazda RX4 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4   54
#> 2     Mazda RX4 Wag 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4   78
#> 3        Datsun 710 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1   86
#> 4    Hornet 4 Drive 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1   58
#> 5 Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2    1
#> 6           Valiant 18.1   6  225 105 2.76 3.460 20.22  1  0    3    1    8

# create list containing data frame to be joined
# create more fake data
fake2 <- sample(1:100,32,replace=FALSE)

# create second data frame
added <- data.frame(Automobile = mtcars$Automobile, fake2)
# confirm that column exists
"Automobile" %in% colnames(added)
#> [1] TRUE
# create objects to place in list

encloser <- list(added)
var1 <- "A"
var2 <- 3.14
var3 <- "b"
var4 <- 2
var5 <- "some string"
var6 <- encloser 
var7 <- "another string"

wrapper <- list(var1, var2, var3, var4, var5, var6, encloser, var7)
str(wrapper)
#> List of 8
#>  $ : chr "A"
#>  $ : num 3.14
#>  $ : chr "b"
#>  $ : num 2
#>  $ : chr "some string"
#>  $ :List of 1
#>   ..$ :'data.frame': 32 obs. of  2 variables:
#>   .. ..$ Automobile: chr [1:32] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive" ...
#>   .. ..$ fake2     : int [1:32] 36 52 95 28 59 46 43 19 62 83 ...
#>  $ :List of 1
#>   ..$ :'data.frame': 32 obs. of  2 variables:
#>   .. ..$ Automobile: chr [1:32] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive" ...
#>   .. ..$ fake2     : int [1:32] 36 52 95 28 59 46 43 19 62 83 ...
#>  $ : chr "another string"
extracted <- wrapper[6][[1]][[1]]
str(extracted)
#> 'data.frame':    32 obs. of  2 variables:
#>  $ Automobile: chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive" ...
#>  $ fake2     : int  36 52 95 28 59 46 43 19 62 83 ...

together <- left_join(result,extracted)
#> Joining, by = "Automobile"
str(together)
#> 'data.frame':    32 obs. of  14 variables:
#>  $ Automobile: chr  "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive" ...
#>  $ mpg       : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
#>  $ cyl       : num  6 6 4 6 8 6 8 4 4 6 ...
#>  $ disp      : num  160 160 108 258 360 ...
#>  $ hp        : num  110 110 93 110 175 105 245 62 95 123 ...
#>  $ drat      : num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
#>  $ wt        : num  2.62 2.88 2.32 3.21 3.44 ...
#>  $ qsec      : num  16.5 17 18.6 19.4 17 ...
#>  $ vs        : num  0 0 1 1 0 1 0 1 1 1 ...
#>  $ am        : num  1 1 1 0 0 0 0 0 0 0 ...
#>  $ gear      : num  4 4 4 3 3 3 3 4 4 4 ...
#>  $ carb      : num  4 4 1 1 2 1 4 2 2 4 ...
#>  $ fake      : int  54 78 86 58 1 8 59 69 73 88 ...
#>  $ fake2     : int  36 52 95 28 59 46 43 19 62 83 ...

Such error usually caused by package conflict. Try to explicitly specify the dplyr package for the select function:

dplyr::select(SampleID, PC1, PC2)

1 Like

Thank you, @kotliary it worked. Am grateful to all of you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.