Created
June 20, 2025 19:49
-
-
Save mvdbeek/d2b46303b2710a6f423fc8c2507832c3 to your computer and use it in GitHub Desktop.
sample for generating a simple csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(GBCC.mcm) | |
library(SummarizedExperiment) | |
library(SpatialFeatureExperiment) | |
x = GBCC.mcm::process_mcmicro("input.h5ad") | |
expr_matrix <- assay(x, "X") | |
expr_df <- as.data.frame(t(expr_matrix)) # Transpose so cells are rows | |
# Get cell metadata | |
metadata <- as.data.frame(colData(x)) | |
# Get spatial coordinates | |
coords <- as.data.frame(spatialCoords(x)) | |
# Combine everything into one comprehensive table | |
combined_data <- cbind( | |
cell_id = rownames(metadata), | |
coords, | |
metadata, | |
expr_df | |
) | |
# Write to CSV | |
write.csv(combined_data, "spatial_expression_data.csv", row.names = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment