Giter VIP home page Giter VIP logo

card's People

Contributors

yingma0107 avatar ymalab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

card's Issues

borders for each dot

Thanks for much for the package. I have a very basic question regarding the plot.

Specifically for CARD.vizualize.prop, I would like to add a scale for the scores. How do I do that?

Thanks,
Lipin

Score the gene set

Hello @YingMa0107,
Thanks for creating CARD! The tool is very useful, it helps me a lot.
Now I have a gene list, I want to score the each gene in this gene list and map the scores into spatial transcriptomic pictures(like the "AddMouduleScore()" function in Seurat),but I can't find this function in CARD.

Overlay with H&E image

Hi!

First of all, thanks for the awesome package. I am analyzing some data we generated using 10x Visium and I was wondering if there is any way to overlay CARD proportions with the original H&E image I have for the tissue? (e.g. as in Figure 3D in your Nat Biotechnol. paper)

So far I have added CARD as an additional Assay in a Seurat object with the images but this does not seem too efficient, and besides that, I cannot do it for the refined spatial map obtained with CARD.imputation.

Thank you in advance,
Alba

Questions about MOB data

Congratulate! I have a question, in the MOB dataset, why do you only select neuron cells to deconvolve? Actually, this isn't a simulated dataset, it's true. Do you think it will affect the results of deconvolution, just as spots would be occupied by immune or non-neuron cells?

Error in Basis[, ict] : subscript out of bounds in CARD_deconvolution

Hi developer, I'm trying to use CARD to perform cell type deconvolution fro my spatial transcriptomics data. Howver, It crashed out with 'Error in Basis[, ict] : subscript out of bounds' in CARD_deconvolution step.

Here is my data and steps:

spatial_count <- ctrl3m_visium@assays$Spatial@counts
print(spatial_count[1:5, 1:4])
spatial_loc <- ctrl3m_visium@images$slice1@coordinates
spatial_loc <- spatial_loc[, c('imagerow', 'imagecol')]
colnames(spatial_loc) <- c('x', 'y')
head(spatial_loc)

sc_count <- scrna_x@assays$RNA@counts
sc_meta <- scrna_x@meta.data[, c('anno', 'anno2', 'sample')]
colnames(sc_meta) <- c('cellType1', 'cellType', 'sampleInfo')

> CARD_obj = createCARDObject(
+     sc_count = sc_count,
+     sc_meta = sc_meta,
+     spatial_count = spatial_count,
+     spatial_location = spatial_loc,
+     ct.varname = "cellType",
+     ct.select = unique(sc_meta$cellType),
+     sample.varname = "sampleInfo",
+     minCountGene = 10,
+     minCountSpot = 2) 
## QC on scRNASeq dataset! ...
## QC on spatially-resolved dataset! ...
> CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)
## create reference matrix from scRNASeq...
## Select Informative Genes! ...
Error in Basis[, ict] : subscript out of bounds


####=============
> sc_eset = CARD_obj@sc_eset
> ct.varname = CARD_obj@info_parameters$ct.varname
> ct.select = CARD_obj@info_parameters$ct.select
> ##### check if the ct.select existing in the single cell RNAseq reference
> print(ct.select  %in% colData(sc_eset)[,ct.varname])
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE


> print(spatial_count[1:5, 1:4])
5 x 4 sparse Matrix of class "dgCMatrix"
        AAACAAGTATCTCCCA-1 AAACAATCTACTAGCA-1 AAACACCAATAACTGC-1 AAACAGAGCGACTCCT-1
Sox17                    1                  .                  .                  1
Mrpl15                   2                  .                  1                  2
Lypla1                   1                  1                  3                  .
Tcea1                    2                  1                  .                  .
Atp6v1h                  .                  .                  .                  .
> head(spatial_loc)
                       x     y
AAACAAGTATCTCCCA-1 13327  7211
AAACAATCTACTAGCA-1  7031 15977
AAACACCAATAACTGC-1  4441  5553
AAACAGAGCGACTCCT-1 12485 13917
AAACAGCTTTCAGAAG-1  3377  8535
AAACAGGGTCTATATT-1  3803  7789

> print(sc_count[1:4, 1:4])
4 x 4 sparse Matrix of class "dgCMatrix"
        AAACCTGAGAGGACGG-CN_3m AAACCTGAGAGTAAGG-CN_3m AAACCTGAGATAGCAT-CN_3m AAACCTGAGATGCCTT-CN_3m
Sox17                        .                      .                      .                      .
Gm37587                      .                      .                      .                      .
Mrpl15                       .                      .                      .                      1
Lypla1                       .                      1                      .                      1
> head(sc_meta)
                       cellType1  cellType sampleInfo
AAACCTGAGAGGACGG-CN_3m      Mast       Neu      CN_3m
AAACCTGAGAGTAAGG-CN_3m Monocytes Monocytes      CN_3m
AAACCTGAGATAGCAT-CN_3m       Neu       Neu      CN_3m
AAACCTGAGATGCCTT-CN_3m Monocytes Monocytes      CN_3m
AAACCTGAGCCCTAAT-CN_3m Monocytes Monocytes      CN_3m
AAACCTGAGGCACATG-CN_3m       Neu       Neu      CN_3m

Could you please hepl me? Thanks.

Install error

Hi,

Thank you for nice work!
However, I have trouble when installing.
Any comment is helpful.

> devtools::install_github('YingMa0107/CARD')
Downloading GitHub repo YingMa0107/CARD@HEAD
Skipping 3 packages not available: Biobase, SummarizedExperiment, SingleCellExperiment
── R CMD build ────────────────────────────────────────────────────────────────
✔  checking for file/private/var/folders/4x/km099l9s3vg276pmnzw1rc9c0000gn/T/RtmpR9KAi5/remotes6b243336790/YingMa0107-CARD-8dffa65/DESCRIPTION...preparingCARD:checking DESCRIPTION meta-information ...cleaning srcinstalling the package to process help pages
         -----------------------------------installing *source* packageCARD...
   ** using staged installation
   ** libs
   clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -Wall -pedantic -fdiagnostics-color=always -c CARDfree.cpp -o CARDfree.o
   clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -Wall -pedantic -fdiagnostics-color=always -c CARDref.cpp -o CARDref.o
   clang++ -arch arm64 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppArmadillo/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -Wall -pedantic -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
   clang++ -arch arm64 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o CARD.so CARDfree.o CARDref.o RcppExports.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lquadmath -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
   ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.6.0/12.0.1'
   ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
   ld: library not found for -lgfortran
   clang: error: linker command failed with exit code 1 (use -v to see invocation)
   make: *** [CARD.so] Error 1
   ERROR: compilation failed for packageCARD’
─  removing/private/var/folders/4x/km099l9s3vg276pmnzw1rc9c0000gn/T/RtmpS9nAPi/Rinstfaa993527c/CARD-----------------------------------
   ERROR: package installation failed
Error: Failed to install 'CARD' from GitHub:
  ! System command 'R' failed
>
> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] SummarizedExperiment_1.28.0 Biobase_2.58.0             
[3] GenomicRanges_1.50.2        GenomeInfoDb_1.34.9        
[5] IRanges_2.32.0              S4Vectors_0.36.2           
[7] BiocGenerics_0.44.0         MatrixGenerics_1.10.0      
[9] matrixStats_0.63.0         

loaded via a namespace (and not attached):
 [1] remotes_2.4.2          purrr_1.0.1            lattice_0.20-45       
 [4] vctrs_0.6.1            miniUI_0.1.1.1         usethis_2.1.6         
 [7] htmltools_0.5.5        rlang_1.1.0            pkgbuild_1.4.0        
[10] urlchecker_1.0.1       later_1.3.0            glue_1.6.2            
[13] withr_2.5.0            sessioninfo_1.2.2      GenomeInfoDbData_1.2.9
[16] lifecycle_1.0.3        stringr_1.5.0          zlibbioc_1.44.0       
[19] devtools_2.4.5         htmlwidgets_1.6.2      memoise_2.0.1         
[22] callr_3.7.3            fastmap_1.1.1          httpuv_1.6.9          
[25] ps_1.7.4               curl_5.0.0             Rcpp_1.0.10           
[28] xtable_1.8-4           promises_1.2.0.1       BiocManager_1.30.20   
[31] cachem_1.0.7           DelayedArray_0.24.0    desc_1.4.2            
[34] pkgload_1.3.2          XVector_0.38.0         mime_0.12             
[37] fs_1.6.1               digest_0.6.31          stringi_1.7.12        
[40] processx_3.8.0         shiny_1.7.4            grid_4.2.3            
[43] rprojroot_2.0.3        cli_3.6.1              tools_4.2.3           
[46] bitops_1.0-7           magrittr_2.0.3         RCurl_1.98-1.12       
[49] profvis_0.3.7          crayon_1.5.2           Matrix_1.5-3          
[52] ellipsis_0.3.2         prettyunits_1.1.1      rstudioapi_0.14       
[55] R6_2.5.1 
>

interpret this result of "CT_*" label using CARDfree method

I am using the CARDfree method for analysis and would like to ask if there is any correspondence between the "CT_*" label obtained in the analysis results and the cell type initially used as data input? Any suggestions on how to interpret this result?

install error

windows 10
collect2.exe: error: ld returned 1 exit status

Empty figure content when I run CARD.visualize.pie in R to generate a spatial pie plot

Hello,

I am running the function CARD.visualize.pie in R to generate a pie spatial plot for 10X Visium data.
However, I get an empty figure which is likely due to the number of spots (>400).
Is there any way to fix this issue and visualize the data in a spatial pie plot?
Other deconvolution tools like DWLS allow to visualize Visium data in a pie spatial plot.
Thank you.

Spots were removed after deconvolution

Dear @YingMa0107 , thanks for your work! When I used CARD for deconvolution, I found some spots were removed in the deconvolution results, how could I preserve these deleted spots? I also tried to set 'minCountGene' and 'minCountSpot' as 0, but several spots were also deleted.

Error in CARD.visualize.gene: selected genes that are not in the expression data!

Hello, thank you so much for providing such a good tool.

I am tring to visualize a gene of interest using CARD.visualize.gene. However, the CARD object seems to have excluded this gene.

Here are all the codes. I once thought that this might be caused be the minCountGene and minCountSpot so I set these two parameters as 0, but I still can't find the gene I want.

CARD_all <- createCARDObject(
  sc_count = sc_count,
  sc_meta = sc_meta,
  spatial_count = spatial_count,
  spatial_location = spatial_location,
  ct.varname = "names_f1",
  ct.select = unique(sc_meta$names_f1),
  sample.varname = "orig.ident",
  minCountGene = 0,
  minCountSpot = 0)

#Deconvolution using CARD
CARD_all <- CARD_deconvolution(CARD_object = CARD_all)

#Refined Grid
CARD_all <- CARD.imputation(CARD_all,NumGrids = 3000,ineibor = 10,exclude = NULL)
location_imputation <- cbind.data.frame(x=as.numeric(sapply(strsplit(rownames(CARD_all@refined_prop),split="x"),"[",1)),
                                       y=as.numeric(sapply(strsplit(rownames(CARD_all@refined_prop),split="x"),"[",2)))
rownames(location_imputation) <- rownames(CARD_all@refined_prop)
CARD.visualize.gene(
  spatial_expression = CARD_all.FC@refined_expression,
  spatial_location = location_imputation,
  gene.visualize = c("Homer1"),
  colors = NULL,
  NumCols = 1)

Error in CARD.visualize.gene(spatial_expression = CARD_all.FC@refined_expression,  : 
  There existing selected genes that are not in the expression data!

Is there some sort of ways to include all the genes? Thank you so much again.

CARD.visualize.prop gives spots that are too large - cannot make smaller?

For our dataset, graphing the results of (the below commands were pulled from the tutorial):

ct.visualize = c("Tumor cells","Immune cells","Mesenchymal cells","Endothelial cells","Schwann cells","Liver cells")
p2 <- CARD.visualize.prop(
  proportion = CARD_obj@Proportion_CARD,
  spatial_location = CARD_obj@spatial_location,
  ct.visualize = ct.visualize,
  NumCols = 4)

using this command:

png("CARD_proportion.png", width=9, height=9, units="in", res=300)
print(p2)
dev.off()

has the following output image:

CARD_proportion

As you can see, all the spots are overlapping. It is unclear how to reduce the size of the generated spots. Checking the man page of the function (with ?CARD.visualize.prop) shows no command to change the size of spots.

I also tried the below command:

png("CARD_proportion.png", width=9, height=9, units="in", res=300)
print(p2) + geom_point(size=0.10)
dev.off()

However, this just produces a new set of black spots (that do respect the geom_point setting) on top of the old data, without altering the size of the spots I actually want to change! See below:

CARD_proportion_geom_point_alteration

How do I change the size of the spots?

How to choose a dominant cell type in one position of spatial transcriptomics data?

Hi, thank you so much for this package!
I was wondering if I could define a cell-type name instead of cell-type proportion for one point of spatial transcriptomics data, such as Stereo-seq or MERFISH, with the single-cell resolution. And in my opinion, whether the cell type with the highest proportion is the dominant cell type? Thanks again for your work on this!

Visium documentation

Hello! I am trying to find the data analysis documentation on the Visium mouse hippocampus dataset that was used in your publication. I can't seem to find it in the github repo nor the documentation website that was linked to the github repo.

Simulation code

Dear @YingMa0107 ,

Thanks for your nice work~ I wonder if you could share the simulation code~?
I think the simulation method you provided is really fascinating !

Best wishes!

Question about PDAC data provided in tutorial

Hi!
I read CARD paper and find a lot of comparison between CARD and other method, so I want to use PDAC data provided in tutorial in RCTD method. But when I create a RCTD object I get an error: 'need a minimum of 25 cells for each cell type in the reference.'
Could you please give me some advice about how to solve this problem?

Recursive default argument in CARD.visualize.pie (colors=colors)

If you don't provide a "colors" argument to CARD.visualize.pie, it throws the error:
promise already under evaluation: recursive default argument reference or earlier problems?

This is (usually) due to the argument being named the same thing as the default it is passed. Renaming either the argument or the object to something other than "colors" will fix it.

Error in running CARDref()

Dear Professor:
I am very interested in the function of CARD's cell type deconvolution, after reading your article. However, when I tried to run CARD with tutorial dataset, the CARDref() function encountered an error.
Everything runs normally, including the createCARDObject function, until the CARD_deconvolution function. The following information appears here:

#########

create reference matrix from scRNASeq...

Select Informative Genes! ...

Deconvolution Starts! ...

Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
Also defined by ‘spam’
Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics'
Also defined by ‘spam’
Error in CARDref(XinputIn = as.matrix(Xinput_norm), UIn = as.matrix(B), :
could not found object '_CARD_CARDref'
#########

Finally, I found that there was a problem in step CARDref(). The input data of CARDref() including XinputIn, UIn, WIn, phiIn, max_iterIn, epsilonIn, initV, initb, initSigma_e2 and initLambda are complete. I will be very grateful if you have any way to solve this problem and inform me.

error(attempt to select less than one element in get1index) when running CARD_deconvolution()

Hi, when I try to run CARD_deconvolution after creating CARDObject, I meet with the error and can you help me ?

CARD_obj = createCARDObject( sc_count = rnacount, sc_meta = rna_meta, spatial_count = spatialcount, spatial_location = spatialInfo, ct.varname = "label", ct.select = unique(rna_meta$label), sample.varname = "timepoint", minCountGene = 100, minCountSpot = 10)

CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)

output:
Select Informative Genes! ...
Deconvolution Starts! ...
Error in ResList[[Optimal]]: attempt to select less than one element in get1index
Traceback:

  1. CARD_deconvolution(CARD_object = CARD_obj)
    attempt to select less than one element in get1index

statistic inference in Cpp

Hi ying:
I'm David Runze Li,congratulations for your work published on NBT, I have learned more, actually i staill have some questions to ask, if you can give me some advices:

  1. in paper supplementary page 121-122 formula 9 and page 122-123 formula 10,you develop new way to estimate matrix V log(pr) and Q,i think this 2 formulas are same especially in statistic, one is to estimate maximum, another one is to estimate minimum., but in your Rcpp line 104-109, i just wonder in this script why you ignore K/2*log(det(L))?

Error in Deconvolution dim(X)

Hi!
When running the deconvolution step of CARD I get this error, I am not sure what the issue is and how dim(X) could be negative.

 CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)
## create reference matrix from scRNASeq...
## Select Informative Genes! ...
Error in apply(temp, 1, var) : dim(X) must have a positive length

Thank you!

Visualization of two cell types together

Hi, thank you so much for this package, I found it very easy to use!
This is not an issue but a suggestion - I was wondering if you have a way to visualize the distributions of two cell types on the same plot. Essentially I would love a function like visualize.prop() that takes in 2 cell types and shows the co-localization (or lack of) between the two on the tissue slice. I know we can see the correlation value from the visualize.Cor() function, but I'd like to be able to see the spatial relationship directly. Thanks again for your work on this!

Error in CARD_deconvolution

Hi
I met a error in CARD_deconvolution cause my data is a little big I think.
This is the error message:

Error in asMethod(object) : 
  Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 102
Calls: CARD_deconvolution ... rowGrpMeans -> as.matrix -> as.matrix -> as -> asMethod
Execution halted

And I tried to convert the format of CARD_obj@sc_eset@assays@data$counts and CARD_obj@spatial_countMat from dgCMatrix to matrix using a self-defined function. But it still called the same error. Any solution of this error? or I convert the wrong dgCMatrix?

Bests.

Library won't install

Hi all, I was trying to give this deconvolution tool a go, however I won't install for some reason. This is the error I get:

library(CARD)
Error: package or namespace load failed for ‘CARD’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘spatstat.utils’ 2.1-0 is already loaded, but >= 2.2.0 is required
In addition: Warning message:
replacing previous import ‘RcppML::nmf’ by ‘NMF::nmf’ when loading ‘CARD’

Thank you.

The area annotation of the MOB spots

Thanks for the fascinating work! Could you mind also sharing the annotation information of Fig 3a about the regions where different spots of the MOB data belong? Thanks so much!

Error in SCMapping when using "Circle" as shapeSpot

Hi,

Thanks so much for making this excellent tool! So far it has been very straightforward to use and helpful to my analysis.

I however am experiencing a slight error when trying the single cell resolution mapping. I ran it with the default "Square" as mentioned in the example analysis, but I tried re-running using "Circle" (I am using Visium spatial data so I think this more accurately represents the spots in my case). This generates the following:

scMapping = CARD_SCMapping(CARD_obj,shapeSpot="Circle",numCell=7,ncore=n.cores)
Error in runifdisc(numCell, radius = min_distance, centre = c(Cords[i,  : 
  could not find function "runifdisc"

I tried installing the surveillance package, which from what I can tell is where runifdisc() originates, but to no avail unfortunately. Any insight on how I might resolve this?

Error in CARD visualization of proportions

Hi!
I am trying to use the visualization function of CARD to visualize the cell type proportions. However, I am getting the same error repeatedly. I tried changing the argument variables to data frames but it doesn't work. Could you help me with a solution to this? This is the error that I get.
image
Thanks, and kind regards,
Shraddha

Can I use normalized expression data as sc_count

Hi CARD team,

I went through the CARD tutorial and noticed that the example sc_count input has the format of raw count (i.e. integer number). I wonder if I can use normalized expression data for sc_count (for example, the typical log-transformed data provided in Seurat @DaTa slot). I have on hands a few very good reference scRNA-seq datasets but they only provide Seurat @DaTa level log-transformed data. I tried to use the log-transformed data as sc_count and the CARD pipeline did run through. But I am not sure whether this negatively impaces the deconvolution quality.

Could you kindly clarify if integer raw count is absolutely required?

Thanks,
Jack

Question regarding the values in Proportion_CARD vs values seen in plot of CARD.visualize.prop

Hi there,

I was just checking the values of the Proportion_CARD slot in CARD_obj and I find that a lot of the values are quite small (<0.01). However, the plots that are generated for the deconvoluted clusters are higher than that.

I went over the script for the CARD.visualize.prop function and I see there are a few lines for scaling and maybe this is why the values are different, specifically
res_CARD_scale = as.data.frame(apply(res_CARD,2,function(x){ (x - min(x)) / (max(x) - min(x)) } ))

I am trying to subset a few spots based on the deconvolution result but since the values don't match up, I can't decide what would be a good cutoff.

Hence, I was wondering if there is a way for me to get the scaled values from the object? Or should I just extract the values and then redo scaling myself.

Thanks,
Lipin

Question regarding normalizing the spatial coordinates

First of all, thank you for sharing the code! I noticed that when constructing the spatial Gaussian kernel, the coordinates are first normalized. More specifically, x an y are first subtracted by their min values, and then divided by the global maximum.

https://github.com/YingMa0107/CARD/blob/dc6a0c82c5239d39507c67202d192551d8e248b6/R/CARD.prop.R#L173-L178

This transformation is pretty similar to the MinMaxScaler in sklearn, except that the max value used here is the global maximum, rather than the column-wise maximum. I'm curious whether there is a specific reason for using the global maximum instead of the columns-wise maximum here.

Issue of installation

Thanks for your great work. Could you please supply the information about the environment (e.g., R version)? It is really hard to install this method in R. Thanks for your help.

Cannot change colours in CARD.visualize.Cor

Hi,

The colours in CARD.visualize.Cor seem to be hard-coded and don't allow the user to change them. Also, the param text suggests the default colours are ("lightblue","lightyellow","red") but they seem to be red, white and green.

Error in running CARD_deconvolution() function

When I try to run the deconvolution I get the following error:

Error in CARDref(XinputIn = as.matrix(Xinput_norm), UIn = as.matrix(B),  : 
  std::bad_alloc

I'm assuming there is some problem with converting a sparse matrix to a matrix? Maybe too much memory demand? or allocation of storage for each iteration causing a memory leak? I will try to run this on a computing cluster to see if it works.

Issue for deconvolution

Thanks for your work first. I would like to ask why this issue emerged when I conducted the deconvolution task?

Error in diag<-(*tmp*, value = 0) :
only matrix diagonals can be replaced

Install error (MacOS Monterey)

Hello @YingMa0107 you did a great job in developing this package !!

I tried installing the package and I am getting error in installation. I am using Mac with M1 chip and macOS Monterey (12.3.1). The error message and the session info can be found below. Thank you in advance for your help.

_** using staged installation
** libs
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include' -I/usr/local/include -fPIC -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c CARDfree.cpp -o CARDfree.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include' -I/usr/local/include -fPIC -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c CARDref.cpp -o CARDref.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include' -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/RcppArmadillo/include' -I/usr/local/include -fPIC -Wall -g -O2 -Wall -pedantic -fdiagnostics-color=always -c RcppExports.cpp -o RcppExports.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o CARD.so CARDfree.o CARDref.o RcppExports.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [CARD.so] Error 1
ERROR: compilation failed for package ‘CARD’
─ removing ‘/private/var/folders/16/2qzgz8cd2bl65zhgv1x6sy0c0000gn/T/Rtmprukk9k/Rinst102f577830c0c/CARD’
-----------------------------------
ERROR: package installation failed
Error: Failed to install 'CARD' from GitHub:
System command 'R' failed, exit status: 1, stdout & stderr were printed

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] pillar_1.7.0 compiler_4.1.2 prettyunits_1.1.1 remotes_2.4.2
[5] tools_4.1.2 testthat_3.1.2 pkgbuild_1.3.1 pkgload_1.2.4
[9] memoise_2.0.1 lifecycle_1.0.1 tibble_3.1.7 pkgconfig_2.0.3
[13] rlang_1.0.2 rstudioapi_0.13 DBI_1.1.2 cli_3.3.0
[17] curl_4.3.2 fastmap_1.1.0 withr_2.4.3 dplyr_1.0.9
[21] generics_0.1.2 desc_1.4.0 fs_1.5.2 vctrs_0.4.1
[25] devtools_2.4.3 rprojroot_2.0.2 tidyselect_1.1.1 glue_1.6.1
[29] R6_2.5.1 processx_3.5.2 fansi_1.0.2 sessioninfo_1.2.2
[33] tidyr_1.2.0 purrr_0.3.4 callr_3.7.0 magrittr_2.0.2
[37] ps_1.6.0 ellipsis_0.3.2 usethis_2.1.5 assertthat_0.2.1
[41] utf8_1.2.2 cachem_1.0.6 crayon_1.4.2 brio_1.1.3_

Originally posted by @utkarsh0493 in #4 (comment)

Error in creating the reference matrix

Dear CARD team-

Thanks for this helpful package to deconvolute spatial data. I created the CARD object. However, I am running into issues while trying to run the CARD deconvolution in the create reference from scRNASeq.

     CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)
    ## create reference matrix from scRNASeq...
     Error in asMethod(object) : 
    Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 102

This could be due to the size of the sparse matrix. Is there a workaround?

   dim(sc_count)
  [1]  32738 167598

Question about inputs: raw vs. normalized counts

Hi, thanks for creating a great tool! I am trying to deconvolute some visium data using publicly available single cell data (eventually we will have single nucleus). I noticed that the tutorial specifies raw data for both the spatial and single cell datasets. I was wondering if the algorithm would be affected by using normalized counts from SCTransform and log2CPM gene expression values for the public single cell data? Right now, I only have access to normalized counts for single cell.

Do you have any suggestions on which data to use?

Any help is appreciated!

Error in running CARD_deconvolution()

Hi, I have created CARD_obj through "creatCARDObject()", then I used this code:

CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)

I will get this error:

create reference matrix from scRNASeq...

Select Informative Genes! ...

Error in Basis[, ict] : subscript out of bounds

This first time, this run, but when I run it again, this error appeared. Could you help me?

Question about single cell resolution mapping on multiple samples

Dear Ying,

I am in the process of utilizing the single cell resolution mapping feature on Spatial Transcriptomic sections that have been generated using 10x Visium. I am planning to study 12 different sections and I intend to utilize the same single cell reference for all of them.

I am concerned about the potential for single-cell duplication across my scMapped objects. Specifically, I am worried that when conducting downstream analysis, the same single-cell may appear in multiple of my objects. Is this a valid concern and, if so, what measures might I take to address this problem or avoid it entirely?

CreateCARDObject error

Hi,

Thank you for the# Make CARD object
CARD_obj = createCARDObject(
sc_count = sc_count,
sc_meta = sc_meta,
spatial_count = spatial_count,
spatial_location = spatial_location,
ct.varname = "cellType",
ct.select = unique(sc_meta$cellType),
sample.varname = "sampleInfo",
minCountGene = 100,
minCountSpot = 5) wonderful tool - I am creating CARDObject and hit an error upon running the code

## QC on scRNASeq dataset! ...
Error in validityMethod(as(object, superClass)) :
object 'Csparse_validate' not found

Not sure where the issue is - appreciate for the help.

Issue of CARD object creation

Hi

Previously I successfully run the deconvolution on one of my four samples also the demo data works as well. However, for my other three data, I failed when creating the CARD object. The error message looks like this:

CARD_obj = createCARDObject(

  • sc_count = sparse_sc_common,
  • sc_meta = CID4465_metadata,
  • spatial_count = sparse_st_common,
  • spatial_location = CID4465_tissue_positions_keep,
  • ct.varname = "cellType",
  • ct.select = unique(CID4465_metadata$cellType),
  • sample.varname = "sampleInfo",
  • minCountGene = 100,
  • minCountSpot = 5)

QC on scRNASeq dataset! ...

QC on spatially-resolved dataset! ...

错误: There are no common gene names in spatial count data and single cell RNAseq count data

Then I check the gene names of two dgcMatrix:

length(intersect(CID4465_st@Dimnames[[1]], CID4465_sc@Dimnames[[1]]))
[1] 17365

There are certainly lots of common gene names between spatial count data and sc RNAseq count data. I use the same code with same data format exactly with the demo and previously succeed one. Any advice would be appreciated, much thanks!

There existing selected genes that are not in the expression data!

Dear Developers,

When I'm trying to visualize one of my interested genes using card in refined resolution, I kept coming to this error:

CARD.visualize.gene(
spatial_expression = naive.card@spatial_countMat,
spatial_location = naive.card@spatial_location,
gene.visualize = c("Penk"),
colors = NULL,
NumCols = 1)

Error in CARD.visualize.gene(spatial_expression = naive.card@refined_expression, :
There existing selected genes that are not in the expression data!

Then I found:
In CARD.obj@spatial_countMat, the number of genes is 10180
In CARD.obj@refined_expression, the number of genes is only 2330.

It seems that, when running CARD.imputation; the refined_expression matrix only use a small part of the whole expression matrix.

So how can I visualize my interested in a refined resolution, if it is not pressented in a refined resoluztion ?

Best Regards,
Huang

Error on CARD_deconvolution: subscript contains invalid names

Hello,

Thank you for putting this nice package together.

I am trying to follow the tutorial using my data. In the step
CARD_obj = CARD_deconvolution(CARD_object = CARD_obj)
I get

## create reference matrix from scRNASeq...
Error: subscript contains invalid names

The traceback is

11: stop(wmsg(...), call. = FALSE)
10: .subscript_error("subscript contains invalid ", what)
9: NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, 
       allow.NAs = allow.NAs)
8: NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, 
       allow.NAs = allow.NAs)
7: normalizeSingleBracketSubscript(i, xstub)
6: extractCOLS(x, j)
5: extractCOLS(x, j)
4: colData(x)[, sample.varname]
3: colData(x)[, sample.varname]
2: createscRef(sc_eset, ct.select, ct.varname, sample.varname)
1: CARD_deconvolution(CARD_object = CARD_obj)

The names of my single cell data are

> colnames(sc_count)[1:3]
[1] "KB13_GCACTAAAGTGATTCC.1"   "KBCVD2_GACACGCGTCCTGAAT.1" "KM102_GATCAGTTCATAGACC.1" 
> rownames(sc_count)[1:3]
[1] "A1BG"     "A1BG-AS1" "A1CF"

Any Idea on how to address this?

Thank you!

Error in running CARD_SCMapping

Hi,

I've been following the tutorial and run into an error when running CARD_SCMapping():

Error in SummarizedExperiment(...) : 
  the rownames and colnames of the supplied assay(s) must be NULL or identical to those of the
  SummarizedExperiment object (or derivative) to construct

I think this may be occurring when the SingleCellExperiment is created in CARD_SCMapping, due to a mismatch in the colnames of count_CT (which have spot and coordinates appended to them) and the rownames of the colData dataframe (which do not have spot and coordinates appended).

Rcpp function CARDfree() can not produce results.

Hi Ying,

We are using the CARDfree for our project. There is an error possibly related to the Rcpp function CARDfree(). I have attached the code, error, and rds object. Could you please help debug?

# Code

CARDfree_obj = createCARDfreeObject(
    markerList = markerList,
    spatial_count = current_expression_Matrix,
    spatial_location = current_position_dataframe,
    minCountGene = 100,
    minCountSpot = 5)
saveRDS(CARDfree_obj, file = "CARDfree_obj.rds")
result_CARDfree_obj = CARD_refFree(CARDfree_obj)

# Error message

## Number of unique marker genes: 1711 for 20 cell types ...
Error in ResList[[Optimal]] : 
  attempt to select less than one element in get1index

# rds file

The file is 54MB, bigger than the GitHuB file size limit 25MB, so I upload it to the dropbox here. There is no need to register the dropbox account.

Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.