Python的字典数据类型是基于hash散列算法实现的,采用键值对(key:value)的形式,根据key的值计算value的地址,具有非常快的查取和插入速度。但它是无序的,包含的元素个数不限,值的类型也可以是其它任何数据类型!
Python的字典数据类型是基于hash散列算法实现的,采用键值对(key:value)的形式,根据key的值计算value的地址,具有非常快的查取和插入速度。但它是无序的,包含的元素个数不限,值的类型也可以是其它任何数据类型!
Position Find( List L, ElementType X ):返回线性表中首次出现X的位置。若找不到则返回ERROR;
本系列是《玩转机器学习教程》一个整理的视频笔记。本小节主要介绍梯度下降法的向量化,并引入对使用梯度下降法非常重要的数据归一化。
具体测试用例分析如下表6-5所示:表 6-5 前台用户注册登录测试用例分析表测试主题测试步骤预期结果实际结果用户注册(1)点击注册,用户输入手机号以及验证码。 用户注册均能正常执行符合预期结果用户登录(1)点击账户登录,用户正确输入用户名密码完成登录 (2)点击手机验证登录,用户正确输入手机号以及收到的验证码完成注册账户名密码登录和短信登录均能正常执行符合预期结果用户登录界面如下图6- 5所示:图 6-5 用户登录界面1.1.2 搜索商品相关功能测试用户搜索商品,当用户输入字符串,这里能够自动补齐关键词,并且点击关键词并能搜索出相应的商品。
pbmc500_assay <- CreateChromatinAssay(pbmc500.counts, fragments = frags.500) pbmc500 <- CreateSeuratObject meta.data=md.500) pbmc1k_assay <- CreateChromatinAssay(pbmc1k.counts, fragments = frags.1k) pbmc1k <- CreateSeuratObject meta.data=md.1k) pbmc5k_assay <- CreateChromatinAssay(pbmc5k.counts, fragments = frags.5k) pbmc5k <- CreateSeuratObject meta.data=md.5k) pbmc10k_assay <- CreateChromatinAssay(pbmc10k.counts, fragments = frags.10k) pbmc10k <- CreateSeuratObject assay <- CreateChromatinAssay(counts = counts.500, sep = c(":", "-"), min.features = 500) pbmc500 <- CreateSeuratObject
1.2 创建seurat对象 依然使用CreateSeuratObject 函数,此处count 为读取的矩阵文件。 sce0 <- CreateSeuratObject(counts = data) sce0 head(sce0@meta.data) An object of class Seurat 19790 1,CreateSeuratObject中的meta.data参数 CreateSeuratObject函数除了简单的过滤条件外 ,还有一个重要的meta.data参数,可以输入提供的meta信息。 检索之后https://github.com/satijalab/seurat/issues/2715 发现 ,是因为CreateSeuratObject要求meta文件中rownames是count文件的 CreateSeuratObject函数的帮助文档中也很明确的提到了该点要求。 发现问题后,只需要将meta文件的cellid列转为rownames即可。
Read10X(data.dir = paste(dataset_loc, ids[1],"filtered_feature_bc_matrix", sep="/")) seurat_obj <- CreateSeuratObject Read10X_h5(file.path(dataset_loc, ids[1], "filtered_feature_bc_matrix.h5"), use.names = T) seurat_obj <- CreateSeuratObject row names as the gene IDs rownames(counts) <- gene_ids colnames(counts) <- cell_ids seurat_obj <- CreateSeuratObject 1L),sep="_") d10x }) seurat_merge <- do.call("cbind", d10x.data) # for "dgCMatrix" seurat_data <- CreateSeuratObject Read10X(data.dir = paste(dataset_loc, file,"filtered_feature_bc_matrix", sep="/")) seurat_obj <- CreateSeuratObject
习题6-5 使用函数验证哥德巴赫猜想 本题要求实现一个判断素数的简单函数,并利用该函数验证哥德巴赫猜想:任何一个不小于6的偶数均可表示为两个奇素数之和。素数就是只能被1和自身整除的正整数。
例6-5显示了一个4选1的多路复用器。在本例中,四个case表达式具有唯一的、不重叠的值。综合器将识别到两个case表达式不可能同时为真,并自动删除case项的优先级编码。 图6-5显示了综合器如何实现case语句。 示例6-5:使用case语句对4选1多路复用器建模 //`begin_keywords "1800-2012" // use SystemVerilog-2012 keywords module mux4to1 = b; 2'b10: y = c; 2'b11: y = d; endcase end endmodule: mux4to1 //`end_keywords 图6- 5:示例6-5的综合结果:综合4选1多路复用器的case语句 例6-5中的case项是互斥的,这意味着其中两个case项不可能同时成立。
dgCMatrix" # attr(,"package") # [1] "Matrix" # 构建 Seurat 对象 # 初步过滤一般不需要修改参数,除非数据实在太难看 Seurat_object <- CreateSeuratObject ScRNAdata <- Read10X_h5(filename = "GSM3489182_Donor_01_raw_gene_bc_matrices_h5.h5") Seurat_object <- CreateSeuratObject read.table( "data/GSM2829942/GSM2829942_HE6W_LA.TPM.txt", row.names = 1, header = T) Seurat_object <- CreateSeuratObject CreateSeuratObject( counts, project = "CreateSeuratObject", assay = "RNA", names.field = 1,
这两天分析一个单细胞数据发现一个奇怪的问题,就是创建 seurat 对象的时候,我明明设置了参数 CreateSeuratObject 函数的project 参数,但是最后merge 不同的样本后发现 > gsub(".txt","", pro) [1] "IRI1d_1" CreateSeuratObject 这个函数做了什么? 赶紧查看 CreateSeuratObject 的帮助文档: Create a Seurat object Description Create a Seurat object from raw data = NULL, project = "CreateSeuratObject", ... ) Arguments counts Either a matrix-like object with # 创建Seurat对象 sce <- CreateSeuratObject(counts = counts, min.cells=3, project = gsub(".txt","", pro),
MACS <- CreateSeuratObject(counts = MACS, project = "H14_MACS", min.cells = 3, min.features = 100) MACS H21 <- CreateSeuratObject(counts = H21, project = "H21", min.cells = 3, min.features = 100) H21 H23 <- CreateSeuratObject(counts = H23, project = "H23", min.cells = 3, min.features = 100) H23 H24 <- CreateSeuratObject = H32, project = "H32", min.cells = 3, min.features = 100) H32 H33 <- CreateSeuratObject(counts = H33 = 3, min.features = 100) H36 H38 <- CreateSeuratObject(counts = H38, project = "H38", min.cells = 3,
如果是单个样品,直接读取进来然后创建seurat对象即可:初试Seurat的V5版本 主要区别在于,V4版本中一般是循环读取样品,使用CreateSeuratObject创建seurat对象,然后使用merge 那我们可以先把多个样品合并成为了一个超级大的表达量矩阵,并使其行名为基因名,列名为barcodes信息,后面直接针对它来使用CreateSeuratObject函数去构建Seurat对象,就是完美的下游分析的输入数据啦 GSE212975/',samples) names(dir) <- samples #读取数据创建Seurat对象 counts <- Read10X(data.dir = dir) sce.all = CreateSeuratObject sceList[[i]])<-paste0(samples[i],"_",col) } #数据整合后创建seurat对象 merge <- do.call(cbind,sceList) sce =CreateSeuratObject F,data.table = F ) head(rl) #整合矩阵信息 colnames(mtx)=cl$V1 rownames(mtx)=rl$V1 #创建seurat对象 sce.all=CreateSeuratObject
,tsv/txt,h5ad格式10x格式的读取展开代码语言:TXTAI代码解释library(Seurat)ct=Read10X(data.dir="GSE145154_RAW/")seu.obj<-CreateSeuratObject install.packages("hdf5r")ct<-Read10X_h5("GSE200874_RAW/GSM6045826_wt_filtered_gene_bc_matrices_h5_2.h5")seu.obj<-CreateSeuratObject row.names=1#是将第一列设置为行名的意思ct<-read.csv("GSE130148_raw_counts.csv.gz",row.names=1)class(ct)seu.obj<-CreateSeuratObject
library("Seurat") scrna_data_ctrl <- Read10X("data/GSE96583/ctrl/") ctrl <- CreateSeuratObject( counts , min.cells = 3, min.features = 200) scrna_data_stim <- Read10X("data/GSE96583/stim/") stim <- CreateSeuratObject sample_list){ filedir = str_c("data/GSE96583/",sample) scrna_data <- Read10X(filedir) Seurat_object <- CreateSeuratObject str_c("data/GSE96583/",sample) # 数据的读取 scrna_data <- Read10X(filedir) # 对象的构建 Seurat_object <- CreateSeuratObject
使用CreateSeuratObject生成Seurat对象,后续分析都是在该对象上进行操作。 rownames(x = raw.data), value = FALSE) raw.data <- raw.data[-ercc.index,] dim(raw.data) 有了表达矩阵,直接使用 CreateSeuratObject 然后慢慢添加这个表达矩阵的一些其它外部属性,全部代码如下: # Create the Seurat object with all the data (unfiltered) main_tiss <- CreateSeuratObject # lapply是对列表或向量进行循环,而apply是对数据框或矩阵操作) library(Seurat) sceList <- lapply(folders,function(folder){ CreateSeuratObject ##### # 读取单个 sce <- Read10X_h5(filename = "GSM4107899_LH16.3814_raw_gene_bc_matrices_h5.h5") sce <- CreateSeuratObject
读取h5格式的文件(使用Read10X_h5函数读取h5格式的单细胞数据文件) seurat_data <- Read10X_h5(file = h5_file) # 创建Seurat对象(使用CreateSeuratObject /data/GSE130148/GSE130148_raw_counts.csv.gz"), row.names = 1) # 使用CreateSeuratObject()函数创建Seurat对象,并在此处指定项目名称 seurat_obj <- CreateSeuratObject(counts = seurat_data, min.features /data/GSE130xxx/xxxx.txt.gz"), row.names = 1, header = TRUE, sep = "\t") # 使用CreateSeuratObject()函数创建 Seurat对象,并在此处指定项目名称 seurat_obj <- CreateSeuratObject(counts = seurat_data,
下面例6-4直接显示出迭代过程中拿到的每一个字符,例6-5通过对索引的遍历,循环显示序列的索引和索引对应的值。 # 例:6-5 a = "abcde" for index in range(len(a)): print(index,a[index]) else: print("索引结束!") PS:例6-5中用到了两个内置函数,解释如下 (1)、len()是python的一个内置函数,用于获取某序列对象的长度。 此外,for循环,也可以遍历序列的索引,例6-5。
tmp = Read10X(file.path(dir,pro )) if(length(tmp)==2){ ct = tmp[[1]] }else{ct = tmp} sce =CreateSeuratObject sce.all_int.rds') GSE152938$study = 'GSE152938' table(GSE152938$orig.ident) sceList = list( GSE131685 = CreateSeuratObject ( counts = GSE131685@assays$RNA$counts ), GSE152938 = CreateSeuratObject( counts = GSE152938