Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

can we use CellChat for species except human and mouse? #38

Open
Brandon-wxm opened this issue Sep 3, 2020 · 17 comments
Open

can we use CellChat for species except human and mouse? #38

Brandon-wxm opened this issue Sep 3, 2020 · 17 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Brandon-wxm
Copy link

Hi, thanks for this nice tool, can you give some suggestions about analysis on other species, like Macaque or Rat? I this maybe we need to replace gene names of human by homologous gene names in Macaque, if so which files should be changed?

Brandon

@sqjin
Copy link
Owner

sqjin commented Sep 4, 2020

Hi @Brandon-wxm , yes, you need to replace gene names of mouse/human by homologous gene names.
First, you need to save four files based on the information in CellChatDB, including 'geneIfo.csv', 'interaction_input_CellChat.csv', 'complex_input_CellChat.csv', 'and cofactor_input_CellChat.csv'.
You can do it as 'CellChatDB <- CellChatDB.mouse
interaction_input <- CellChatDB$interaction
complex_input <- CellChatDB$complex
cofactor_input <- CellChatDB$cofactor
geneInfo <- CellChatDB$geneIfo
write.csv(interaction_input, file = "interaction_input_CellChatDB.csv") '

Second, you need to find the homologous genes in these files.

Third, run the following codes to update the database options(stringsAsFactors = FALSE) interaction_input <- read.csv(file = 'interaction_input_CellChat.csv') row.names(interaction_input) <- interaction_input[,1] complex_input <- read.csv(file = 'complex_input_CellChat.csv', row.names = 1) cofactor_input <- read.csv(file = 'cofactor_input_CellChat.csv', row.names = 1) CellChatDB <- list() CellChatDB$interaction <- interaction_input CellChatDB$complex <- complex_input CellChatDB$cofactor <- cofactor_input CellChatDB$geneInfo <- geneIfo CellChatDB.macaque <- CellChatDB.

Fourth (optional), you can re-build CellChat package by updating the database as follows devtools::use_data(CellChatDB.macaque, overwrite = TRUE)

@Brandon-wxm
Copy link
Author

Wow, thank you so much, best wishes!

@sqjin sqjin added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 7, 2020
@patrickfletcher
Copy link

Dear sqjin,

I am trying to make a CellChatDB to study rat data. Could you confirm that the change needed for the files above is to change the "Symbol" appearances in each of the files you mentioned? Specifically:
interaction_input: ligand column
complex_input: all gene names
cofactor_input: all gene names
geneInfo: Symbol column

Should the remaining columns in geneInfo also be updated?

Thanks for your help,

Patrick

@sqjin
Copy link
Owner

sqjin commented May 18, 2021

@patrickfletcher In addition to the four updates you mentioned, you also need to change the gene names in receptor column in the interaction_input file. If the element in the receptor column is a complex (i.e., not a gene name), no need to change. If the element in the receptor column is a gene name, change it to be a homologous gene. Note that there are also several ligands with multiple subunits (e.g. IL12AB and IL23 complex) in the 'ligand column', no need to change them.

In summary, please replace the mouse gene name by the corresponding homologous gene appearances in each of the following files:

    • interaction_input: ligand column and receptor column
    • complex_input: all gene names
    • cofactor_input: all gene names
    • geneInfo: Symbol column

I appreciate if you'd like to make contribution to the development of CellChatDB by sharing your rat database. You could contribute it via the 'Pull requests'.

@xiaonian92
Copy link

Hi Brandon-wxm and dear author, I have successfully set up a new database for pig by following your instructions. However, when I run cellchat <- subsetData(cellchat), I got :Issue identified!! Please check the offical Gene Symbol of the following genes: 469, 470, 471, 29, 30 ... .... And if I omitted this warning, I got very few df.net.
So, could you please give me some advice? Thank you so much!

@TYU1201
Copy link

TYU1201 commented Sep 16, 2021

Dear sqjin,

Do you think it is feasible to replace the line name of the RDS file (rat gene name) with the homologous gene name of the mouse? This seems a lot easier than the above method.

Thank you very much
ty

@apdavid
Copy link

apdavid commented Feb 11, 2022

CellChat team,

I am trying to make a CellChatDB for chicken (G. gallus). The code is below, however when I run the showDatabaseCategory() function I get the following error:

Error: `idx` must contain one integer for each level of `f`

Am I creating the CellChatDB correctly?

Thank you for any help you can provide.

Abel

Here is my code:

library(CellChat)
library(patchwork)
options(stringsAsFactors = FALSE)
library(biomaRt)
library(magrittr)
library(tidyverse)
library(dplyr)

# Save Four Files from CellChatDB

# 1a. Load CellChatDB Reference Files

CellChatDB <- CellChatDB.mouse

# Pull Mouse Information
geneInfo <- CellChatDB$geneInfo
interaction_input <- CellChatDB$interaction
complex_input <- CellChatDB$complex
cofactor_input <- CellChatDB$cofactor

# Write Mouse Information
write.csv(geneInfo, file = "geneInfo.csv")
write.csv(interaction_input, file = "interaction_input_CellChatDB.csv")
write.csv(complex_input, file = "complex_input_CellChat.csv")
write.csv(cofactor_input, file = "cofactor_input_CellChat.csv")

# 1b. Load BioMart chicken and mouse gene nomenclature

# Find Chx Homologues
chicken <- useMart('ensembl', dataset = 'ggallus_gene_ensembl')
mouse <- useMart('ensembl', dataset = 'mmusculus_gene_ensembl')
annot_table <- getLDS(
  mart = mouse,
  attributes = c('ensembl_gene_id','mgi_symbol','external_gene_name','chromosome_name'),
  martL = chicken,
  attributesL = c('ensembl_gene_id','external_gene_name','chromosome_name','gene_biotype'))
head(annot_table)

# Create Cross Reference Table Based on Ensembl Gene ID
xref_table <- annot_table %>% 
  dplyr::select(Gene.stable.ID, Gene.name, Gene.stable.ID.1, Gene.name.1) %>% 
  dplyr::rename(Ensembl.Gene.ID = Gene.stable.ID)

# 2. Replace Genes

# geneInfo: Symbol column
# there are duplicates in the Gene Info rownames
geneInfo.chicken <- geneInfo %>% 
  rownames_to_column("row_names") %>%
  inner_join(xref_table, by = "Ensembl.Gene.ID") %>% 
  rename(Symbol.mouse = Symbol) %>% 
  rename(Symbol.chicken = Gene.name.1) %>% 
  mutate(Symbol = Symbol.chicken) %>% 
  na_if("") %>% 
  na.omit()

geneInfo.chicken <- geneInfo.chicken[!duplicated(geneInfo.chicken$Symbol),]

# interaction_input: ligand column and receptor column
ligands <- geneInfo.chicken %>% 
  dplyr::select(Symbol.mouse, Symbol.chicken) %>% 
  rename(ligand = Symbol.mouse, ligand.chicken = Symbol.chicken)
receptors <- geneInfo.chicken %>% 
  dplyr::select(Symbol.mouse, Symbol.chicken) %>% 
  rename(receptor = Symbol.mouse, receptor.chicken = Symbol.chicken)

interaction_input.chicken <- interaction_input %>% 
  inner_join(ligands, by = "ligand") %>% 
  inner_join(receptors, by = "receptor") %>%
  rename(ligand.mouse = ligand) %>% 
  rename(receptor.mouse = receptor) %>% 
  rename(ligand = ligand.chicken) %>% 
  rename(receptor = receptor.chicken)
          
# complex_input: subunit_1 ... subunit_4
mouse2chicken <- geneInfo.chicken %>% 
  dplyr::select(Symbol.mouse, Symbol.chicken) %>% 
  rename(value = Symbol.mouse) %>% 
  unique()

complex_input.chicken <- complex_input %>% 
  rownames_to_column("row_names") %>%
  pivot_longer(cols = subunit_1:subunit_4) %>%
  inner_join(mouse2chicken, by = "value") %>% 
  pivot_wider(id_cols = row_names, names_from = name, values_from = Symbol.chicken, values_fn = first, values_fill = "") %>%
  column_to_rownames(var = "row_names")

# cofactor_input: cofactor1 ... cofactor16

mouse2chicken <- geneInfo.chicken %>% dplyr::select(Symbol.mouse, Symbol.chicken) %>% rename(value = Symbol.mouse) %>% unique()

cofactor_input.chicken <- cofactor_input %>% 
  rownames_to_column("row_names") %>%
  pivot_longer(cols = cofactor1:cofactor16) %>%
  inner_join(mouse2chicken, by = "value") %>% 
  pivot_wider(id_cols = row_names, names_from = name, values_from = Symbol.chicken, values_fn = first, values_fill = "") %>%
  column_to_rownames(var = "row_names")

# 3. Update the Database
options(stringsAsFactors = FALSE) 
CellChatDB <- list() 
CellChatDB$interaction <- interaction_input.chicken 
CellChatDB$complex <- complex_input.chicken
CellChatDB$cofactor <- cofactor_input.chicken
CellChatDB$geneInfo <- geneInfo.chicken
CellChatDB.chicken <- CellChatDB

#interaction_input <- read.csv(file = 'interaction_input_CellChat.csv') 
#row.names(interaction_input) <- interaction_input[,1] 
#complex_input <- read.csv(file = 'complex_input_CellChat.csv', row.names = 1) 
#cofactor_input <- read.csv(file = 'cofactor_input_CellChat.csv', row.names = 1) 

# 4. Rebuild (optional) - WIP, but can just use the object.
# devtools::use_data(CellChatDB.chicken, overwrite = TRUE)
# usethis::use_data(CellChatDB.mouse, overwrite = TRUE)

showDatabaseCategory(CellChatDB, nrow = 1)

@rahulnutron
Copy link

Hi CellChat team,

Can I use a plant database in cellchat? I am trying to build the database for Arabidopsis using https://jasonxu.shinyapps.io/PlantPhoneDB/ database. The data in the interaction column looks like as below, however when running

cellchat <- subsetData(cellchat)

gives the below error.

Issue identified!! Please check the official Gene Symbol of the following genes:AT1G01900 AT1G01980...

I will be grateful for any help!
Rahul

head(CellChatDB$interaction)
interaction_name pathway_name ligand receptor agonist antagonist co_A_receptor co_I_receptor evidence
AT1G01900_AT2G02220 AT1G01900_AT2G02220 NA AT1G01900 AT2G02220 NA NA NA NA NA
AT1G01900_AT3G02130 AT1G01900_AT3G02130 NA AT1G01900 AT3G02130 NA NA NA NA NA
AT1G01980_AT5G10770 AT1G01980_AT5G10770 NA AT1G01980 AT5G10770 NA NA NA NA NA
AT1G02640_AT5G09870 AT1G02640_AT5G09870 NA AT1G02640 AT5G09870 NA NA NA NA NA
AT1G02640_AT4G13800 AT1G02640_AT4G13800 NA AT1G02640 AT4G13800 NA NA NA NA NA
AT1G02790_AT4G14815 AT1G02790_AT4G14815 NA AT1G02790 AT4G14815 NA NA NA NA NA
annotation interaction_name_2
AT1G01900_AT2G02220 NA NA
AT1G01900_AT3G02130 NA NA
AT1G01980_AT5G10770 NA NA
AT1G02640_AT5G09870 NA NA
AT1G02640_AT4G13800 NA NA
AT1G02790_AT4G14815 NA NA

@sqjin
Copy link
Owner

sqjin commented Nov 12, 2022

@rahulnutron Yes, you can run cellchat once you have built the plant database. Do you have the official plant gene name in CellChatDB.plant$geneInfo? If so, I think it may be fine to get rid of these genes.

@rahulnutron
Copy link

Thanks! I will try to re-build the database once again. No I don't have the gene names in "geneInfo" slot.

@elainarose97
Copy link

Hi @apdavid I am also trying to run CellChat analysis on the chicken. I am wondering if you got it to work and if you could share how you did it? Thanks so much!

@rxz1l
Copy link

rxz1l commented Apr 21, 2023

@rahulnutron I want to build a rice database, but encountered some issues during the implementation. I'd like to ask if you have successfully built your database? If so, could you kindly provide some insights on what information you have modified?

@sqjin
Copy link
Owner

sqjin commented Apr 24, 2023

@rahulnutron I want to build a rice database, but encountered some issues during the implementation. I'd like to ask if you have successfully built your database? If so, could you kindly provide some insights on what information you have modified?

Can you send me the required csv files for building the database so that I can identify the issue.

@dravichandar
Copy link

dravichandar commented Jun 19, 2023

Curious, instead of converting the database, would it still work to simply convert the cell chat object?
For example if I am starting with a rat-seuratobject

ortho <- dataframe with 1:1 rat-mouse gene mapping
data.input <- GetAssayData(sobj, assay = "RNA", slot = "data")# Get normalized data
data.input <- data.input[intersect(rownames(data.input),ortho$rat_name),]#subset to rat genes that are 1:1 orthologs of mouse
rownames(data.input) <- plyr::mapvalues(rownames(data.input),ortho$rat_name,ortho$`Mouse gene name`,warn_missing = F)# Convert rat to mouse

cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")#make cell chat object

@sqjin
Copy link
Owner

sqjin commented Jun 24, 2023 via email

@doctorinsecto
Copy link

Hi @elainarose97, did he ever get back to you/did you ever figure this out?

@tdaf
Copy link

tdaf commented Nov 17, 2023

hello @apdavid and @elainarose97 , did you ever get it to work for the chicken?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests