Last active
November 1, 2022 11:16
-
-
Save j-andrews7/c2a6c11379d1f6ad402eb8a1e09cd113 to your computer and use it in GitHub Desktop.
Revisions
-
j-andrews7 revised this gist
Jun 5, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,9 @@ add_clonotype <- function(tcr_location, seurat_obj){ tcr <- read.csv(paste(tcr_folder,"filtered_contig_annotations.csv", sep="")) # Remove the -1 at the end of each barcode. # Subsets so only the first line of each barcode is kept, # as each entry for given barcode will have same clonotype. tcr$barcode <- gsub("-1", "", tcr$barcode) tcr <- tcr[!duplicated(tcr$barcode), ] -
j-andrews7 revised this gist
Jun 5, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,6 @@ add_clonotype <- function(tcr_location, seurat_obj){ # Only keep the barcode and clonotype columns. # We'll get additional clonotype info from the clonotype table. tcr <- tcr[,c("barcode", "raw_clonotype_id")] names(tcr)[names(tcr) == "raw_clonotype_id"] <- "clonotype_id" -
j-andrews7 created this gist
Jun 5, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ add_clonotype <- function(tcr_location, seurat_obj){ tcr <- read.csv(paste(tcr_folder,"filtered_contig_annotations.csv", sep="")) # Remove the -1 at the end of each barcode, and subsets so only the first line of each barcode is kept. tcr$barcode <- gsub("-1", "", tcr$barcode) tcr <- tcr[!duplicated(tcr$barcode), ] # Only keep the barcode and clonotype columns. # We'll get additional clonotype info from the clonotype table. # This one runs the risk of yielding fragments that might not be the consensus for the clonotype. tcr <- tcr[,c("barcode", "raw_clonotype_id")] names(tcr)[names(tcr) == "raw_clonotype_id"] <- "clonotype_id" # Clonotype-centric info. clono <- read.csv(paste(tcr_folder,"clonotypes.csv", sep="")) # Slap the AA sequences onto our original table by clonotype_id. tcr <- merge(tcr, clono[, c("clonotype_id", "cdr3s_aa")]) # Reorder so barcodes are first column and set them as rownames. tcr <- tcr[, c(2,1,3)] rownames(tcr) <- tcr[,1] tcr[,1] <- NULL # Add to the Seurat object's metadata. clono_seurat <- AddMetaData(object=seurat_obj, metadata=tcr) return(clono_seurat) }