Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update integration_introduction.Rmd #5398

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

simonmfr
Copy link

Matched the number of provided cell types to number of factor levels of immune.combined. Using 0:14 results in a warning:

> immune.combined <- RenameIdents(immune.combined, `0` = "CD14 Mono", `1` = "CD4 Naive T", `2` = "CD4 Memory T",
+                                 `3` = "CD16 Mono", `4` = "B", `5` = "CD8 T", `6` = "NK", `7` = "T activated", `8` = "DC", `9` = "B Activated",
+                                 `10` = "Mk", `11` = "pDC", `12` = "Eryth", `13` = "Mono/Mk Doublets", `14` = "HSPC")
Warning: Cannot find identity 14

Reason:

levels(Idents(immune.combined))
 [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13"

Matched number of provided cell types to number of factor levels of immune.combined. Using 0:14 results in a warning:

> immune.combined <- RenameIdents(immune.combined, `0` = "CD14 Mono", `1` = "CD4 Naive T", `2` = "CD4 Memory T",
+                                 `3` = "CD16 Mono", `4` = "B", `5` = "CD8 T", `6` = "NK", `7` = "T activated", `8` = "DC", `9` = "B Activated",
+                                 `10` = "Mk", `11` = "pDC", `12` = "Eryth", `13` = "Mono/Mk Doublets", `14` = "HSPC")
Warning: Cannot find identity 14

Reason: 
levels(Idents(immune.combined))
 [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13"
@samuel-marsh
Copy link
Collaborator

Hi,

Not member of dev team but wanted to confirm what code you are running. When I copy and paste the following code from the vignette it runs without error for me and there are 15 idents (including ident 14):

library(Seurat)
library(SeuratData)
library(patchwork)

AvailableData()

# install dataset
InstallData("ifnb")
# load dataset
LoadData("ifnb")

# split the dataset into a list of two seurat objects (stim and CTRL)
ifnb.list <- SplitObject(ifnb, split.by = "stim")

# normalize and identify variable features for each dataset independently
ifnb.list <- lapply(X = ifnb.list, FUN = function(x) {
  x <- NormalizeData(x)
  x <- FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
})

# select features that are repeatedly variable across datasets for integration
features <- SelectIntegrationFeatures(object.list = ifnb.list)
immune.anchors <- FindIntegrationAnchors(object.list = ifnb.list, anchor.features = features)
# this command creates an 'integrated' data assay
immune.combined <- IntegrateData(anchorset = immune.anchors)
# specify that we will perform downstream analysis on the corrected data note that the
# original unmodified data still resides in the 'RNA' assay
DefaultAssay(immune.combined) <- "integrated"

# Run the standard workflow for visualization and clustering
immune.combined <- ScaleData(immune.combined, verbose = FALSE)
immune.combined <- RunPCA(immune.combined, npcs = 30, verbose = FALSE)
immune.combined <- RunUMAP(immune.combined, reduction = "pca", dims = 1:30)
immune.combined <- FindNeighbors(immune.combined, reduction = "pca", dims = 1:30)
immune.combined <- FindClusters(immune.combined, resolution = 0.5)


# Visualization
p1 <- DimPlot(immune.combined, reduction = "umap", group.by = "stim")
p2 <- DimPlot(immune.combined, reduction = "umap", label = TRUE, repel = TRUE)
p1 + p2


immune.combined <- RenameIdents(immune.combined, `0` = "CD14 Mono", `1` = "CD4 Naive T", `2` = "CD4 Memory T",
                                `3` = "CD16 Mono", `4` = "B", `5` = "CD8 T", `6` = "NK", `7` = "T activated", `8` = "DC", `9` = "B Activated",
                                `10` = "Mk", `11` = "pDC", `12` = "Eryth", `13` = "Mono/Mk Doublets", `14` = "HSPC")
DimPlot(immune.combined, label = TRUE)

@simonmfr
Copy link
Author

@samuel-marsh If I run the same code I still get

> levels(Idents(immune.combined))
 [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13"

I don't know why this is different from yours - but I guess it is better to leave the code as is and risk a warning. Thanks for mentioning.

@samuel-marsh
Copy link
Collaborator

@simonmfr interesting... ya no idea

leaving sessionInfo here in case devs are interested:

sessionInfo
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C              LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] patchwork_1.1.1         pbmc3k.SeuratData_3.1.4 ifnb.SeuratData_3.1.0   SeuratData_0.2.1        SeuratObject_4.0.4      Seurat_4.0.5           

loaded via a namespace (and not attached):
  [1] nlme_3.1-153          matrixStats_0.61.0    spatstat.sparse_2.0-0 RcppAnnoy_0.0.19      RColorBrewer_1.1-2    httr_1.4.2            sctransform_0.3.2     tools_4.1.2           utf8_1.2.2            R6_2.5.1             
 [11] irlba_2.3.5           rpart_4.1-15          KernSmooth_2.23-20    uwot_0.1.11           mgcv_1.8-38           DBI_1.1.1             lazyeval_0.2.2        colorspace_2.0-2      tidyselect_1.1.1      gridExtra_2.3        
 [21] compiler_4.1.2        cli_3.1.0             plotly_4.10.0         scales_1.1.1          lmtest_0.9-39         spatstat.data_2.1-0   ggridges_0.5.3        pbapply_1.5-0         rappdirs_0.3.3        goftest_1.2-3        
 [31] stringr_1.4.0         digest_0.6.29         spatstat.utils_2.2-0  pkgconfig_2.0.3       htmltools_0.5.2       parallelly_1.29.0     fastmap_1.1.0         htmlwidgets_1.5.4     rlang_0.4.12          rstudioapi_0.13      
 [41] shiny_1.7.1           generics_0.1.1        zoo_1.8-9             jsonlite_1.7.2        ica_1.0-2             dplyr_1.0.7           magrittr_2.0.1        Matrix_1.3-4          Rcpp_1.0.7            munsell_0.5.0        
 [51] fansi_0.5.0           abind_1.4-5           reticulate_1.22       lifecycle_1.0.1       stringi_1.7.6         MASS_7.3-54           Rtsne_0.15            plyr_1.8.6            grid_4.1.2            parallel_4.1.2       
 [61] listenv_0.8.0         promises_1.2.0.1      ggrepel_0.9.1         crayon_1.4.2          miniUI_0.1.1.1        deldir_1.0-6          lattice_0.20-45       cowplot_1.1.1         splines_4.1.2         tensor_1.5           
 [71] pillar_1.6.4          igraph_1.2.9          spatstat.geom_2.3-0   future.apply_1.8.1    reshape2_1.4.4        codetools_0.2-18      leiden_0.3.9          glue_1.5.1            data.table_1.14.2     png_0.1-7            
 [81] vctrs_0.3.8           httpuv_1.6.3          gtable_0.3.0          RANN_2.6.1            purrr_0.3.4           spatstat.core_2.3-2   polyclip_1.10-0       tidyr_1.1.4           scattermore_0.7       future_1.23.0        
 [91] assertthat_0.2.1      ggplot2_3.3.5         mime_0.12             xtable_1.8-4          RSpectra_0.16-0       later_1.3.0           survival_3.2-13       viridisLite_0.4.0     tibble_3.1.6          cluster_2.1.2        
[101] globals_0.14.0        fitdistrplus_1.1-6    ellipsis_0.3.2        ROCR_1.0-11   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants